/** * <p>filterSubtypesForDeserialization</p> * * @param logger a {@link com.google.gwt.core.ext.TreeLogger} object. * @param configuration a {@link com.github.nmorel.gwtjackson.rebind.RebindConfiguration} object. * @param type a {@link com.google.gwt.core.ext.typeinfo.JClassType} object. * @return a {@link com.google.gwt.thirdparty.guava.common.collect.ImmutableList} object. */ public static ImmutableList<JClassType> filterSubtypesForDeserialization( TreeLogger logger, RebindConfiguration configuration, JClassType type ) { boolean filterOnlySupportedType = isObjectOrSerializable( type ); ImmutableList.Builder<JClassType> builder = ImmutableList.builder(); if ( type.getSubtypes().length > 0 ) { for ( JClassType subtype : type.getSubtypes() ) { if ( (null == subtype.isInterface() && !subtype.isAbstract() && (!subtype.isMemberType() || subtype.isStatic())) && null == subtype.isAnnotation() && subtype.isPublic() && (!filterOnlySupportedType || (configuration.isTypeSupportedForDeserialization( logger, subtype ) // EnumSet and EnumMap are not supported in subtype deserialization because we can't know the enum to use. && !EnumSet.class.getCanonicalName().equals( subtype.getQualifiedSourceName() ) && !EnumMap.class.getCanonicalName().equals( subtype.getQualifiedSourceName() ))) && !findFirstEncounteredAnnotationsOnAllHierarchy( configuration, subtype.isClassOrInterface(), JsonIgnoreType.class, Optional.of( type ) ).isPresent() ) { builder.add( subtype ); } } } return builder.build(); }
parameterDeserializerType = getJsonDeserializerFromType( typeArgs[i], subtype ); parametersDeserializerBuilder.add( parameterDeserializerType ); ImmutableList<JDeserializerType> parametersDeserializer = parametersDeserializerBuilder.build(); builder.parameters( parametersDeserializer ); builder.instance( methodCallCodeWithJMapperTypeParameters( configuredDeserializer.get(), parametersDeserializer ) ); for ( JType argType : typeParameters ) { JDeserializerType jsonDeserializer = getJsonDeserializerFromType( argType, subtype ); parametersDeserializerBuilder.add( new JParameterizedDeserializer( getKeyDeserializerFromType( argType, subtype, true ), jsonDeserializer ) ); parametersJsonDeserializerBuilder.add( jsonDeserializer ); builder.parameters( parametersJsonDeserializerBuilder.build() ); builder.beanMapper( true ); builder.instance( constructorCallCode( ClassName.get( mapperInfo.getPackageName(), mapperInfo.getSimpleDeserializerClassName() ), parametersDeserializerBuilder .build() ) ); return builder.build();
parameterSerializerType = getJsonSerializerFromType( typeArgs[i], subtype ); parametersSerializerBuilder.add( parameterSerializerType ); ImmutableList<JSerializerType> parametersSerializer = parametersSerializerBuilder.build(); builder.parameters( parametersSerializer ); builder.instance( methodCallCodeWithJMapperTypeParameters( configuredSerializer.get(), parametersSerializer ) ); for ( JType argType : typeParameters ) { JSerializerType jsonSerializer = getJsonSerializerFromType( argType, subtype ); parametersSerializerBuilder.add( new JParameterizedSerializer( getKeySerializerFromType( argType, subtype, true ), jsonSerializer ) ); parametersJsonSerializerBuilder.add( jsonSerializer ); builder.parameters( parametersJsonSerializerBuilder.build() ); builder.beanMapper( true ); builder.instance( constructorCallCode( ClassName.get( mapperInfo.getPackageName(), mapperInfo.getSimpleSerializerClassName() ), parametersSerializerBuilder .build() ) ); return builder.build();
parameterDeserializerType = getJsonDeserializerFromType( typeArgs[i], subtype ); parametersDeserializerBuilder.add( parameterDeserializerType ); ImmutableList<JDeserializerType> parametersDeserializer = parametersDeserializerBuilder.build(); builder.parameters( parametersDeserializer ); builder.instance( methodCallCodeWithJMapperTypeParameters( keyDeserializer.get(), parametersDeserializer ) );
parameterSerializerType = getJsonSerializerFromType( typeArgs[i], subtype ); parametersSerializerBuilder.add( parameterSerializerType ); ImmutableList<JSerializerType> parametersSerializer = parametersSerializerBuilder.build(); builder.parameters( parametersSerializer ); builder.instance( methodCallCodeWithJMapperTypeParameters( keySerializer.get(), parametersSerializer ) );
case None: repeatText = " no-repeat"; listBuilder.add(buildHeightDeclaration(imageResource, sourceCodeLocation)); listBuilder.add(buildWidthDeclaration(imageResource, sourceCodeLocation)); break; case Horizontal: repeatText = " repeat-x"; listBuilder.add(buildHeightDeclaration(imageResource, sourceCodeLocation)); break; case Vertical: repeatText = " repeat-y"; listBuilder.add(buildWidthDeclaration(imageResource, sourceCodeLocation)); break; case Both: listBuilder.add(buildOverflowDeclaration(sourceCodeLocation)); listBuilder.add(buildBackgroundDeclaration(imageResource, repeatText, sourceCodeLocation)); visitController.replaceCurrentBlockChildWith(listBuilder.build(), false);
case None: repeatText = " no-repeat"; listBuilder.add(buildHeightDeclaration(imageResource, sourceCodeLocation)); listBuilder.add(buildWidthDeclaration(imageResource, sourceCodeLocation)); break; case Horizontal: repeatText = " repeat-x"; listBuilder.add(buildHeightDeclaration(imageResource, sourceCodeLocation)); break; case Vertical: repeatText = " repeat-y"; listBuilder.add(buildWidthDeclaration(imageResource, sourceCodeLocation)); break; case Both: listBuilder.add(buildOverflowDeclaration(sourceCodeLocation)); listBuilder.add(buildBackgroundDeclaration(imageResource, repeatText, sourceCodeLocation)); visitController.replaceCurrentBlockChildWith(listBuilder.build(), false);
/** * <p>filterSubtypesForSerialization</p> * * @param logger a {@link com.google.gwt.core.ext.TreeLogger} object. * @param configuration a {@link com.github.nmorel.gwtjackson.rebind.RebindConfiguration} object. * @param type a {@link com.google.gwt.core.ext.typeinfo.JClassType} object. * @return a {@link com.google.gwt.thirdparty.guava.common.collect.ImmutableList} object. */ public static ImmutableList<JClassType> filterSubtypesForSerialization( TreeLogger logger, RebindConfiguration configuration, JClassType type ) { boolean filterOnlySupportedType = isObjectOrSerializable( type ); ImmutableList.Builder<JClassType> builder = ImmutableList.builder(); if ( type.getSubtypes().length > 0 ) { for ( JClassType subtype : type.getSubtypes() ) { if ( null == subtype.isAnnotation() && subtype.isPublic() && (!filterOnlySupportedType || configuration.isTypeSupportedForSerialization( logger, subtype )) && !findFirstEncounteredAnnotationsOnAllHierarchy( configuration, subtype.isClassOrInterface(), JsonIgnoreType.class, Optional.of( type ) ).isPresent()) { builder.add( subtype ); } } } return builder.build(); }
/** * @return the list of default configuration + user configurations */ private List<AbstractConfiguration> getAllConfigurations() throws UnableToCompleteException { ImmutableList.Builder<AbstractConfiguration> builder = ImmutableList.builder(); builder.add( new DefaultConfiguration() ); ConfigurationProperty property = null; try { property = context.getPropertyOracle().getConfigurationProperty( CONFIGURATION_EXTENSION_PROPERTY ); } catch ( BadPropertyValueException e ) { logger.log( Type.WARN, "Cannot find the property " + CONFIGURATION_EXTENSION_PROPERTY ); } if ( null != property && !property.getValues().isEmpty() ) { for ( String value : property.getValues() ) { try { builder.add( (AbstractConfiguration) Class.forName( value ).newInstance() ); } catch ( Exception e ) { logger.log( Type.ERROR, "Cannot instantiate the configuration class " + value ); throw new UnableToCompleteException(); } } } return builder.build(); }
/** * Returns an event indicating the current status of each active job, in the order they were * submitted. * TODO: hook this up. */ synchronized ImmutableList<JobEvent> getActiveEvents() { ImmutableList.Builder<JobEvent> builder = ImmutableList.builder(); for (String id : activeJobIds) { JobEvent p = eventsByJobId.get(id); assert p != null; builder.add(p); } return builder.build(); } }
/** * Returns an event indicating the current status of each active job, in the order they were * submitted. * TODO: hook this up. */ synchronized ImmutableList<JobEvent> getActiveEvents() { ImmutableList.Builder<JobEvent> builder = ImmutableList.builder(); for (String id : activeJobIds) { JobEvent p = eventsByJobId.get(id); assert p != null; builder.add(p); } return builder.build(); } }
/** * If all the given tags are valid, returns a list containing the tags. * @throws java.lang.IllegalArgumentException if any tag is invalid. */ static ImmutableList<String> checkTags(Iterable<String> tags) { ImmutableList.Builder<String> builder = ImmutableList.builder(); for (String tag : tags) { if (!isValidTag(tag)) { throw new IllegalArgumentException("invalid tag: " + tag); } builder.add(tag); } return builder.build(); }
/** * If all the given tags are valid, returns a list containing the tags. * @throws java.lang.IllegalArgumentException if any tag is invalid. */ static ImmutableList<String> checkTags(Iterable<String> tags) { ImmutableList.Builder<String> builder = ImmutableList.builder(); for (String tag : tags) { if (!isValidTag(tag)) { throw new IllegalArgumentException("invalid tag: " + tag); } builder.add(tag); } return builder.build(); }
case None: repeatText = " no-repeat"; listBuilder.add(buildHeightDeclaration(imageResource, sourceCodeLocation)); listBuilder.add(buildWidthDeclaration(imageResource, sourceCodeLocation)); break; case Horizontal: repeatText = " repeat-x"; listBuilder.add(buildHeightDeclaration(imageResource, sourceCodeLocation)); break; case Vertical: repeatText = " repeat-y"; listBuilder.add(buildWidthDeclaration(imageResource, sourceCodeLocation)); break; case Both: listBuilder.add(buildOverflowDeclaration(sourceCodeLocation)); listBuilder.add(buildBackgroundDeclaration(imageResource, repeatText, sourceCodeLocation)); visitController.replaceCurrentBlockChildWith(listBuilder.build(), false);