package com.fasterxml.jackson.failing;

import com.fasterxml.jackson.databind.BaseMapTest;
import com.fasterxml.jackson.databind.ObjectMapper;

/**
 * Tests Scala-style JVM naming patterns for properties.
 *
 * Scala uses identifiers that are legal JVM names, but not legal Java names:
 *
 * <ul>
 *     <li><code>prop␣</code> (trailing space) for fields</li>
 *     <li><code>prop</code> for getters</li>
 *     <li><code>prop_=</code> for setters</li>
 * </ul>
 *
 * Scala sources turn property accesses into method calls in most cases; the
 * backing field and the particulars of the method names are implementation details.
 *
 * Since I can't reproduce them in Java, I've substituted legal but uncommonly
 * used characters as placeholders.
 */
public class TestScalaLikeImplicitProperties extends BaseMapTest
{
    static class ValProperty
    {
        public String prop‿ = "val";
        public String prop() { return prop‿; }
    }

    static class VarProperty
    {
        public String prop‿ = "var";
        public String prop() { return prop‿; }
        public void prop_⁀(String p) { prop‿ = p; }
    }

    static class GetterSetterProperty
    {
        // Different name to represent an arbitrary implementation, not necessarily local to this class.
        private String _prop_impl = "get/set";
        public String prop() { return _prop_impl; }
        public void prop_⁀(String p) { _prop_impl = p; }
    }


    public void testValProperty() throws Exception
    {
        ObjectMapper m = new ObjectMapper();

        // TODO: Activate whatever handler implements the property detection style

        assertEquals("{\"prop\":\"val\"}", m.writeValueAsString(new ValProperty()));
    }


    public void testVarProperty() throws Exception
    {
        ObjectMapper m = new ObjectMapper();

        // TODO: Activate whatever handler implements the property detection style

        assertEquals("{\"prop\":\"var\"}", m.writeValueAsString(new VarProperty()));
        VarProperty result = m.readValue("{\"prop\":\"read\"}", VarProperty.class);
        assertEquals("read", result.prop());
    }


    public void testGetterSetterProperty() throws Exception
    {
        ObjectMapper m = new ObjectMapper();

        // TODO: Activate whatever handler implements the property detection style

        assertEquals("{\"prop\":\"get/set\"}", m.writeValueAsString(new GetterSetterProperty()));
        GetterSetterProperty result = m.readValue("{\"prop\":\"read\"}", GetterSetterProperty.class);
        assertEquals("read", result.prop());
    }
}

@@ -852,32 +852,38 @@
 %0A        public 
+final 
 String prop%E2%80%BF = %22
@@ -882,16 +882,8 @@
 rop%E2%80%BF
- = %22val%22
 ;%0A  
@@ -922,24 +922,103 @@
 urn prop%E2%80%BF; %7D
+%0A%0A        public ValProperty(String prop) %7B%0A            prop%E2%80%BF = prop;%0A        %7D
 %0A    %7D%0A%0A    
@@ -1079,16 +1079,8 @@
 rop%E2%80%BF
- = %22var%22
 ;%0A  
@@ -1171,24 +1171,103 @@
 prop%E2%80%BF = p; %7D
+%0A%0A        public VarProperty(String prop) %7B%0A            prop%E2%80%BF = prop;%0A        %7D
 %0A    %7D%0A%0A    
@@ -1566,16 +1566,237 @@
 l = p; %7D
+%0A%0A        // Getter/Setters are typically not in the constructor because they are implemented%0A        // by the end user, not the compiler. They should be detected similar to 'bean-style'%0A        // getProp/setProp pairs.
 %0A    %7D%0A%0A
@@ -2055,32 +2055,37 @@
 new ValProperty(
+%22val%22
 )));%0A    %7D%0A%0A%0A   
@@ -2260,32 +2260,32 @@
 etection style%0A%0A
-
         assertEq
@@ -2340,32 +2340,37 @@
 new VarProperty(
+%22var%22
 )));%0A        Var

Add Scala-style constructors