public SampleMappings(final Type type) { super(new MapperConfig( new ConcurrentHashMap<AdapterKey, Adapter<?, ?>>(), new HashMap<Class<?>, ObjectConverter.Writer<?>>(), new HashMap<Class<?>, ObjectConverter.Reader<?>>(), -1, true, true, true, false, false, false, new FieldAndMethodAccessMode(false, false, false), StandardCharsets.UTF_8, new Comparator<String>() { @Override public int compare(final String o1, final String o2) { return o1.compareTo(o2); } }, false)); this.type = type; }
@Override public Map<String, Reader> doFindReaders(final Class<?> clazz) { if (Stream.of(clazz.getInterfaces()).anyMatch(it -> it.getName().startsWith("routines.system."))) { final Map<String, Reader> readers = fields.findReaders(clazz); if (!readers.isEmpty()) { return readers; } // else let's try the methods } return super.doFindReaders(clazz); } }
private Class<?> toType(final Type type) { return Class.class.isInstance(type) ? Class.class.cast(type) : (ParameterizedType.class.isInstance(type) ? toType(ParameterizedType.class.cast(type).getRawType()) : Object.class /*fallback*/); }
final Method m = getMethod("set" + Character.toUpperCase(key.charAt(0)) + (key.length() > 1 ? key.substring(1) : ""), clazz, toType(entry.getValue().getType())); boolean skip = false; if (m != null) { final Method mr = MethodAccessMode.MethodDecoratedType.class.cast(entry.getValue()).getMethod(); final String fieldName = Introspector.decapitalize(mr.getName().startsWith("is") ? mr.getName().substring(2) : mr.getName().substring(3)); final Field f = getField(fieldName, clazz); boolean skip = false; if (f != null) {
Method m = getMethod("get" + Character.toUpperCase(key.charAt(0)) + (key.length() > 1 ? key.substring(1) : ""), clazz); if (m == null && (boolean.class == entry.getValue().getType() || Boolean.class == entry.getValue().getType())) { m = getMethod("is" + Character.toUpperCase(key.charAt(0)) + (key.length() > 1 ? key.substring(1) : ""), clazz); final Method mr = MethodAccessMode.MethodDecoratedType.class.cast(entry.getValue()).getMethod(); final String fieldName = Introspector.decapitalize(mr.getName().startsWith("is") ? mr.getName().substring(2) : mr.getName().substring(3)); final Field f = getField(fieldName, clazz); boolean skip = false; if (f != null) {
final Method m = getMethod("set" + Character.toUpperCase(key.charAt(0)) + (key.length() > 1 ? key.substring(1) : ""), clazz, toType(entry.getValue().getType())); boolean skip = false; if (m != null) { final Method mr = MethodAccessMode.MethodDecoratedType.class.cast(entry.getValue()).getMethod(); final String fieldName = Introspector.decapitalize(mr.getName().startsWith("is") ? mr.getName().substring(2) : mr.getName().substring(3)); final Field f = getField(fieldName, clazz); boolean skip = false; if (f != null) {
Method m = getMethod("get" + Character.toUpperCase(key.charAt(0)) + (key.length() > 1 ? key.substring(1) : ""), clazz); if (m == null && (boolean.class == entry.getValue().getType() || Boolean.class == entry.getValue().getType())) { m = getMethod("is" + Character.toUpperCase(key.charAt(0)) + (key.length() > 1 ? key.substring(1) : ""), clazz); final Method mr = MethodAccessMode.MethodDecoratedType.class.cast(entry.getValue()).getMethod(); final String fieldName = Introspector.decapitalize(mr.getName().startsWith("is") ? mr.getName().substring(2) : mr.getName().substring(3)); final Field f = getField(fieldName, clazz); boolean skip = false; if (f != null) {
config.getProperty("johnzon.accessModeDelegate") .map(this::toAccessMode) .orElseGet(() -> new FieldAndMethodAccessMode(true, true, false)))); builder.setAccessMode(accessMode);
private Class<?> toType(final Type type) { return Class.class.isInstance(type) ? Class.class.cast(type) : (ParameterizedType.class.isInstance(type) ? toType(ParameterizedType.class.cast(type).getRawType()) : Object.class /*fallback*/); }
config.getProperty("johnzon.accessModeDelegate") .map(this::toAccessMode) .orElseGet(() -> new FieldAndMethodAccessMode(true, true, false)))); builder.setAccessMode(accessMode);
accessMode = new MethodAccessMode(supportConstructors, supportHiddenAccess, false); } else if ("both".equalsIgnoreCase(accessModeName) || accessModeName == null) { accessMode = new FieldAndMethodAccessMode(supportConstructors, supportHiddenAccess, useGetterForCollections); } else { throw new IllegalArgumentException("Unsupported access mode: " + accessModeName);
accessMode = new MethodAccessMode(supportConstructors, supportHiddenAccess, false); } else if ("both".equalsIgnoreCase(accessModeName) || accessModeName == null) { accessMode = new FieldAndMethodAccessMode(supportConstructors, supportHiddenAccess, useGetterForCollections); } else { throw new IllegalArgumentException("Unsupported access mode: " + accessModeName);