private static boolean validateWildcardSerializable(MetaClass mc) { if (mc.isInterface() || (mc.isAbstract() && !mc.isEnum())) { log.debug("Serializable types cannot be an interface or abstract, ignoring: {}", mc.getFullyQualifiedName()); return false; } return true; }
private static boolean validateWildcardSerializable(MetaClass mc) { if (mc.isInterface() || (mc.isAbstract() && !mc.isEnum())) { log.debug("Serializable types cannot be an interface or abstract, ignoring: {}", mc.getFullyQualifiedName()); return false; } return true; }
public static boolean canHandle(final MetaClass type, final String mimeType) { boolean canHandle = false; if (("text/plain".equals(mimeType) && type.asUnboxed().isPrimitive()) || type.equals(MetaClassFactory.get(String.class)) || type.equals(MetaClassFactory.get(Date.class)) || type.isEnum()) { canHandle = true; } return canHandle; }
@Override public boolean shouldUseObjectMarshaller(final MetaClass type) { final boolean hasPortableSubtypes = inheritanceMap.containsKey(type.getFullyQualifiedName()); final MappingDefinition definition = getDefinition(type); final boolean hasMarshaller = definition != null; if (hasMarshaller) { if (definition.getClass().isAnnotationPresent(CustomMapping.class) || definition.getClientMarshallerClass() != null) { return false; } } final boolean isConcrete = !(type.isAbstract() || type.isInterface()); if (!type.isArray() && !type.isEnum() && !isConcrete && !hasPortableSubtypes) { throw new IllegalStateException("A field of type " + type + " appears in a portable class, but " + type + " has no portable implementations."); } return (hasPortableSubtypes && !hasMarshaller) || (hasPortableSubtypes && hasMarshaller && isConcrete); }
@Override public boolean shouldUseObjectMarshaller(final MetaClass type) { final boolean hasPortableSubtypes = inheritanceMap.containsKey(type.getFullyQualifiedName()); final MappingDefinition definition = getDefinition(type); final boolean hasMarshaller = definition != null; if (hasMarshaller) { if (definition.getClass().isAnnotationPresent(CustomMapping.class) || definition.getClientMarshallerClass() != null) { return false; } } final boolean isConcrete = !(type.isAbstract() || type.isInterface()); if (!type.isArray() && !type.isEnum() && !isConcrete && !hasPortableSubtypes) { throw new IllegalStateException("A field of type " + type + " appears in a portable class, but " + type + " has no portable implementations."); } return (hasPortableSubtypes && !hasMarshaller) || (hasPortableSubtypes && hasMarshaller && isConcrete); }
final Class cls = o.getClass(); if (definition.getMappingClass().isEnum()) { final Enum enumer = (Enum) o;
final Class cls = o.getClass(); if (definition.getMappingClass().isEnum()) { final Enum enumer = (Enum) o;
public boolean isConcrete() { return !isInterface() && !isAbstract() && !isSynthetic() && !isAnonymousClass() && !isPrimitive() && !isArray() && !isAnnotation() && !isEnum(); }
public boolean isConcrete() { return !isInterface() && !isAbstract() && !isSynthetic() && !isAnonymousClass() && !isPrimitive() && !isArray() && !isAnnotation() && !isEnum(); }
if ((toMap.isAbstract() || toMap.isInterface()) && !toMap.isEnum()) { throw new RuntimeException("cannot map an abstract class or interface: " + toMap.getFullyQualifiedName());
public Statement unwrapJSON(final Statement valueStatement, final MetaClass toType, final MetaClass targetType) { if (toType.isEnum()) { return demarshallEnum(Stmt.nestedCall(valueStatement).invoke("isObject"), valueStatement, toType); } else { final String varName = MarshallingGenUtil.getVarName(toType); if (toType.equals(MetaClassFactory.get(Object.class))) { return Stmt.castTo(ObjectMarshaller.class, Stmt.loadVariable(varName)) .invoke("demarshall", targetType.asClass(), valueStatement, loadVariable("a1")); } return Stmt.loadVariable(varName) .invoke("demarshall", valueStatement, loadVariable("a1")); } }
public Statement unwrapJSON(final Statement valueStatement, final MetaClass toType, final MetaClass targetType) { if (toType.isEnum()) { return demarshallEnum(Stmt.nestedCall(valueStatement).invoke("isObject"), valueStatement, toType); } else { final String varName = MarshallingGenUtil.getVarName(toType); if (toType.equals(MetaClassFactory.get(Object.class))) { return Stmt.castTo(ObjectMarshaller.class, Stmt.loadVariable(varName)) .invoke("demarshall", targetType.asClass(), valueStatement, loadVariable("a1")); } return Stmt.loadVariable(varName) .invoke("demarshall", valueStatement, loadVariable("a1")); } }
if (mapping.getType().isEnum()) { enums.add(mapping.getType());
if (mapping.getType().isEnum()) { enums.add(mapping.getType());
public static MappingDefinition map(final MetaClass toMap, final DefinitionsFactory definitionsFactory) { if ((toMap.isAbstract() && !toMap.isEnum()) || toMap.isInterface()) { throw new RuntimeException("cannot marshal an abstract class or interface: " + toMap.getFullyQualifiedName()); definition.setInstantiationMapping(simpleConstructorMapping); if (toMap.isEnum()) { return definition; final MetaClass compType = type.isArray() ? type.getOuterComponentType().asBoxed() : type.asBoxed(); if (!(compType.isAbstract() || compType.isInterface() || compType.isEnum()) && !definitionsFactory.isExposedClass(compType)) { throw new InvalidMappingException("portable entity " + toMap.getFullyQualifiedName() + " contains a field (" + field.getName() + ") that is not known to the marshaller framework: "
public static MappingDefinition map(final MetaClass toMap, final DefinitionsFactory definitionsFactory) { if ((toMap.isAbstract() && !toMap.isEnum()) || toMap.isInterface()) { throw new RuntimeException("cannot marshal an abstract class or interface: " + toMap.getFullyQualifiedName()); definition.setInstantiationMapping(simpleConstructorMapping); if (toMap.isEnum()) { return definition; final MetaClass compType = type.isArray() ? type.getOuterComponentType().asBoxed() : type.asBoxed(); if (!(compType.isAbstract() || compType.isInterface() || compType.isEnum()) && !definitionsFactory.isExposedClass(compType)) { throw new InvalidMappingException("portable entity " + toMap.getFullyQualifiedName() + " contains a field (" + field.getName() + ") that is not known to the marshaller framework: "
if (toMap.isEnum()) { builder.append(Stmt.load(marshallEnum(loadVariable("a0"), toMap)).returnValue()); return; targetType.isArray() ? targetType.getOuterComponentType().asBoxed() : targetType.asBoxed(); if (!(compType.isAbstract() || compType.isInterface() || compType.isEnum()) && !context.canMarshal(compType.getFullyQualifiedName())) { throw new NoAvailableMarshallerException(compType.getFullyQualifiedName()); concat = Str.expr(concat, StringOperator.Concat, "\":"); if (targetType.isEnum()) { concat = Str.expr(concat, StringOperator.Concat, Expr.qualify(marshallEnum(valueStatement, targetType)));
if (toMap.isEnum()) { builder.append(Stmt.load(marshallEnum(loadVariable("a0"), toMap)).returnValue()); return; targetType.isArray() ? targetType.getOuterComponentType().asBoxed() : targetType.asBoxed(); if (!(compType.isAbstract() || compType.isInterface() || compType.isEnum()) && !context.canMarshal(compType.getFullyQualifiedName())) { throw new NoAvailableMarshallerException(compType.getFullyQualifiedName()); concat = Str.expr(concat, StringOperator.Concat, "\":"); if (targetType.isEnum()) { concat = Str.expr(concat, StringOperator.Concat, Expr.qualify(marshallEnum(valueStatement, targetType)));
.initializeWith(loadVariable("a0").invoke("isObject"))); if (toMap.isEnum()) { builder.append(Stmt.declareVariable(toMap).named("entity") .initializeWith(demarshallEnum(loadVariable("obj"), loadVariable("a0"), toMap)));
.initializeWith(loadVariable("a0").invoke("isObject"))); if (toMap.isEnum()) { builder.append(Stmt.declareVariable(toMap).named("entity") .initializeWith(demarshallEnum(loadVariable("obj"), loadVariable("a0"), toMap)));