/** * Collection support is limited to value types and resolving ids. */ public static Object decode(EntitySource source, Class<?> type, Class<?> elementType, String jsonPayload) { Splittable split = StringQuoter.split(jsonPayload); return decode(source, type, elementType, split); }
/** * Handles instance invocations as the instance at the 0th parameter. */ private List<Object> decodeInvocationArguments(RequestState source, List<Splittable> parameters, Class<?>[] contextArgs, Type[] genericArgs) { if (parameters == null) { // Can't return Collections.emptyList() because this must be mutable return new ArrayList<Object>(); } assert parameters.size() == contextArgs.length; List<Object> args = new ArrayList<Object>(contextArgs.length); for (int i = 0, j = contextArgs.length; i < j; i++) { Class<?> type = contextArgs[i]; Class<?> elementType = null; Splittable split; if (Collection.class.isAssignableFrom(type)) { elementType = TypeUtils.ensureBaseType(TypeUtils.getSingleParameterization(Collection.class, genericArgs[i])); split = parameters.get(i); } else { split = parameters.get(i); } Object arg = EntityCodex.decode(source, type, elementType, split); arg = source.getResolver().resolveDomainValue(arg, !EntityProxyId.class.equals(contextArgs[i])); args.add(arg); } return args; }
void onSuccess(Splittable split) { // The user may not have called to() if (receiver != null) { @SuppressWarnings("unchecked") T result = (T) EntityCodex.decode(requestContext, requestData.getReturnType(), requestData .getElementType(), split); receiver.onSuccess(result); } }
value = ValueCodex.decode(valueType, valueSplit); } else { value = decode(source, valueType, null, valueSplit); throw new UnsupportedOperationException(); List<?> keys = (List<?>) decode(source, List.class, keyType, split.get(0)); List<?> values = (List<?>) decode(source, List.class, valueType, split.get(1)); if (keys.size() != values.size()) { throw new UnsupportedOperationException();
@Override public boolean visitReferenceProperty(String propertyName, AutoBean<?> value, PropertyContext ctx) { if (ctx.canSet()) { if (properties.containsKey(propertyName)) { Splittable raw = properties.get(propertyName); Object decoded = null; if (ctx.getType() == Map.class) { MapPropertyContext mapCtx = (MapPropertyContext) ctx; Class<?> keyType = mapCtx.getKeyType(); Class<?> valueType = mapCtx.getValueType(); decoded = EntityCodex.decode(AbstractRequestContext.this, mapCtx.getType(), keyType, valueType, raw); } else { Class<?> elementType = ctx instanceof CollectionPropertyContext ? ((CollectionPropertyContext) ctx) .getElementType() : null; decoded = EntityCodex.decode(AbstractRequestContext.this, ctx.getType(), elementType, raw); } ctx.set(decoded); } } return false; }
collection.add(null); } else { Object element = decode(source, elementType, null, split.get(i)); collection.add(element);
@Override public boolean visitReferenceProperty(String propertyName, AutoBean<?> value, PropertyContext ctx) { // containsKey to distinguish null from unknown if (flatValueMap.containsKey(propertyName)) { Object resolved = null; // The null check on getKeyType() is necessary as some of the given PropertyContext's // implement both MapPropertyContext and CollectionPropertyContext. if (ctx.getType() == Map.class) { MapPropertyContext mapCtx = (MapPropertyContext) ctx; Class<?> keyType = mapCtx.getKeyType(); Class<?> valueType = mapCtx.getValueType(); Object newValue = EntityCodex.decode(state, mapCtx.getType(), keyType, valueType, flatValueMap.get(propertyName)); resolved = state.getResolver().resolveDomainValue(newValue, false); } else { Class<?> elementType = ctx instanceof CollectionPropertyContext ? ((CollectionPropertyContext) ctx) .getElementType() : null; Object newValue = EntityCodex.decode(state, ctx.getType(), elementType, flatValueMap .get(propertyName)); resolved = state.getResolver().resolveDomainValue(newValue, false); } service.setProperty(domain, propertyName, service.resolveDomainClass(ctx.getType()), resolved); } return false; }
/** * Collection support is limited to value types and resolving ids. */ public static Object decode(EntitySource source, Class<?> type, Class<?> elementType, String jsonPayload) { Splittable split = StringQuoter.split(jsonPayload); return decode(source, type, elementType, split); }
/** * Collection support is limited to value types and resolving ids. */ public static Object decode(EntitySource source, Class<?> type, Class<?> elementType, String jsonPayload) { Splittable split = StringQuoter.split(jsonPayload); return decode(source, type, elementType, split); }
/** * Collection support is limited to value types and resolving ids. */ public static Object decode(EntitySource source, Class<?> type, Class<?> elementType, String jsonPayload) { Splittable split = StringQuoter.split(jsonPayload); return decode(source, type, elementType, split); }
/** * Handles instance invocations as the instance at the 0th parameter. */ private List<Object> decodeInvocationArguments(RequestState source, List<Splittable> parameters, Class<?>[] contextArgs, Type[] genericArgs) { if (parameters == null) { // Can't return Collections.emptyList() because this must be mutable return new ArrayList<Object>(); } assert parameters.size() == contextArgs.length; List<Object> args = new ArrayList<Object>(contextArgs.length); for (int i = 0, j = contextArgs.length; i < j; i++) { Class<?> type = contextArgs[i]; Class<?> elementType = null; Splittable split; if (Collection.class.isAssignableFrom(type)) { elementType = TypeUtils.ensureBaseType(TypeUtils.getSingleParameterization(Collection.class, genericArgs[i])); split = parameters.get(i); } else { split = parameters.get(i); } Object arg = EntityCodex.decode(source, type, elementType, split); arg = source.getResolver().resolveDomainValue(arg, !EntityProxyId.class.equals(contextArgs[i])); args.add(arg); } return args; }
/** * Handles instance invocations as the instance at the 0th parameter. */ private List<Object> decodeInvocationArguments(RequestState source, List<Splittable> parameters, Class<?>[] contextArgs, Type[] genericArgs) { if (parameters == null) { // Can't return Collections.emptyList() because this must be mutable return new ArrayList<Object>(); } assert parameters.size() == contextArgs.length; List<Object> args = new ArrayList<Object>(contextArgs.length); for (int i = 0, j = contextArgs.length; i < j; i++) { Class<?> type = contextArgs[i]; Class<?> elementType = null; Splittable split; if (Collection.class.isAssignableFrom(type)) { elementType = TypeUtils.ensureBaseType(TypeUtils.getSingleParameterization(Collection.class, genericArgs[i])); split = parameters.get(i); } else { split = parameters.get(i); } Object arg = EntityCodex.decode(source, type, elementType, split); arg = source.getResolver().resolveDomainValue(arg, !EntityProxyId.class.equals(contextArgs[i])); args.add(arg); } return args; }
void onSuccess(Splittable split) { // The user may not have called to() if (receiver != null) { @SuppressWarnings("unchecked") T result = (T) EntityCodex.decode(requestContext, requestData.getReturnType(), requestData .getElementType(), split); receiver.onSuccess(result); } }
void onSuccess(Splittable split) { // The user may not have called to() if (receiver != null) { @SuppressWarnings("unchecked") T result = (T) EntityCodex.decode(requestContext, requestData.getReturnType(), requestData .getElementType(), split); receiver.onSuccess(result); } }
void onSuccess(Splittable split) { // The user may not have called to() if (receiver != null) { @SuppressWarnings("unchecked") T result = (T) EntityCodex.decode(requestContext, requestData.getReturnType(), requestData .getElementType(), split); receiver.onSuccess(result); } }
@Override public boolean visitReferenceProperty(String propertyName, AutoBean<?> value, PropertyContext ctx) { if (ctx.canSet()) { if (properties.containsKey(propertyName)) { Splittable raw = properties.get(propertyName); Object decoded = null; if (ctx.getType() == Map.class) { MapPropertyContext mapCtx = (MapPropertyContext) ctx; Class<?> keyType = mapCtx.getKeyType(); Class<?> valueType = mapCtx.getValueType(); decoded = EntityCodex.decode(AbstractRequestContext.this, mapCtx.getType(), keyType, valueType, raw); } else { Class<?> elementType = ctx instanceof CollectionPropertyContext ? ((CollectionPropertyContext) ctx) .getElementType() : null; decoded = EntityCodex.decode(AbstractRequestContext.this, ctx.getType(), elementType, raw); } ctx.set(decoded); } } return false; }
@Override public boolean visitReferenceProperty(String propertyName, AutoBean<?> value, PropertyContext ctx) { if (ctx.canSet()) { if (properties.containsKey(propertyName)) { Splittable raw = properties.get(propertyName); Object decoded = null; if (ctx.getType() == Map.class) { MapPropertyContext mapCtx = (MapPropertyContext) ctx; Class<?> keyType = mapCtx.getKeyType(); Class<?> valueType = mapCtx.getValueType(); decoded = EntityCodex.decode(AbstractRequestContext.this, mapCtx.getType(), keyType, valueType, raw); } else { Class<?> elementType = ctx instanceof CollectionPropertyContext ? ((CollectionPropertyContext) ctx) .getElementType() : null; decoded = EntityCodex.decode(AbstractRequestContext.this, ctx.getType(), elementType, raw); } ctx.set(decoded); } } return false; }
@Override public boolean visitReferenceProperty(String propertyName, AutoBean<?> value, PropertyContext ctx) { if (ctx.canSet()) { if (properties.containsKey(propertyName)) { Splittable raw = properties.get(propertyName); Object decoded = null; if (ctx.getType() == Map.class) { MapPropertyContext mapCtx = (MapPropertyContext) ctx; Class<?> keyType = mapCtx.getKeyType(); Class<?> valueType = mapCtx.getValueType(); decoded = EntityCodex.decode(AbstractRequestContext.this, mapCtx.getType(), keyType, valueType, raw); } else { Class<?> elementType = ctx instanceof CollectionPropertyContext ? ((CollectionPropertyContext) ctx) .getElementType() : null; decoded = EntityCodex.decode(AbstractRequestContext.this, ctx.getType(), elementType, raw); } ctx.set(decoded); } } return false; }
@Override public boolean visitReferenceProperty(String propertyName, AutoBean<?> value, PropertyContext ctx) { // containsKey to distinguish null from unknown if (flatValueMap.containsKey(propertyName)) { Object resolved = null; // The null check on getKeyType() is necessary as some of the given PropertyContext's // implement both MapPropertyContext and CollectionPropertyContext. if (ctx.getType() == Map.class) { MapPropertyContext mapCtx = (MapPropertyContext) ctx; Class<?> keyType = mapCtx.getKeyType(); Class<?> valueType = mapCtx.getValueType(); Object newValue = EntityCodex.decode(state, mapCtx.getType(), keyType, valueType, flatValueMap.get(propertyName)); resolved = state.getResolver().resolveDomainValue(newValue, false); } else { Class<?> elementType = ctx instanceof CollectionPropertyContext ? ((CollectionPropertyContext) ctx) .getElementType() : null; Object newValue = EntityCodex.decode(state, ctx.getType(), elementType, flatValueMap .get(propertyName)); resolved = state.getResolver().resolveDomainValue(newValue, false); } service.setProperty(domain, propertyName, service.resolveDomainClass(ctx.getType()), resolved); } return false; }
@Override public boolean visitReferenceProperty(String propertyName, AutoBean<?> value, PropertyContext ctx) { // containsKey to distinguish null from unknown if (flatValueMap.containsKey(propertyName)) { Object resolved = null; // The null check on getKeyType() is necessary as some of the given PropertyContext's // implement both MapPropertyContext and CollectionPropertyContext. if (ctx.getType() == Map.class) { MapPropertyContext mapCtx = (MapPropertyContext) ctx; Class<?> keyType = mapCtx.getKeyType(); Class<?> valueType = mapCtx.getValueType(); Object newValue = EntityCodex.decode(state, mapCtx.getType(), keyType, valueType, flatValueMap.get(propertyName)); resolved = state.getResolver().resolveDomainValue(newValue, false); } else { Class<?> elementType = ctx instanceof CollectionPropertyContext ? ((CollectionPropertyContext) ctx) .getElementType() : null; Object newValue = EntityCodex.decode(state, ctx.getType(), elementType, flatValueMap .get(propertyName)); resolved = state.getResolver().resolveDomainValue(newValue, false); } service.setProperty(domain, propertyName, service.resolveDomainClass(ctx.getType()), resolved); } return false; }