Package org.codehaus.jackson.map.module

Examples of org.codehaus.jackson.map.module.SimpleModule


    // initialize the state manager after the anonymizers are registered
    statePool.initialize(getConf());
    
    outMapper = new ObjectMapper();
    // define a module
    SimpleModule module = new SimpleModule("Anonymization Serializer"
                                           new Version(0, 1, 1, "FINAL"));
    // add various serializers to the module
    // use the default (as-is) serializer for default data types
    module.addSerializer(DataType.class, new DefaultRumenSerializer());
    // use a blocking serializer for Strings as they can contain sensitive
    // information
    module.addSerializer(String.class, new BlockingSerializer());
    // use object.toString() for object of type ID
    module.addSerializer(ID.class, new ObjectStringSerializer<ID>());
    // use getAnonymizedValue() for data types that have the anonymizing
    // feature
    module.addSerializer(AnonymizableDataType.class,
        new DefaultAnonymizingRumenSerializer(statePool, getConf()));
   
    // register the module with the object-mapper
    outMapper.registerModule(module);
   
View Full Code Here


    ObjectMapper mapper = new ObjectMapper();
    mapper.configure(
        DeserializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS, true);
   
    // define a module
    SimpleModule module = new SimpleModule("State Serializer"
        new Version(0, 1, 1, "FINAL"));
    // add the state deserializer
    module.addDeserializer(StatePair.class, new StateDeserializer());

    // register the module with the object-mapper
    mapper.registerModule(module);

    JsonParser parser =
View Full Code Here

    System.out.println("Dumping the StatePool's in JSON format.");
    ObjectMapper outMapper = new ObjectMapper();
    outMapper.configure(
        SerializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS, true);
    // define a module
    SimpleModule module = new SimpleModule("State Serializer"
        new Version(0, 1, 1, "FINAL"));
    // add the state serializer
    //module.addSerializer(State.class, new StateSerializer());

    // register the module with the object-mapper
View Full Code Here

    ObjectMapper mapper = new ObjectMapper();
    mapper.configure(
        SerializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS, true);

    // define a module
    SimpleModule module = new SimpleModule("Default Serializer"
                                           new Version(0, 1, 1, "FINAL"));
    // add various serializers to the module
    //   add default (all-pass) serializer for all rumen specific data types
    module.addSerializer(DataType.class, new DefaultRumenSerializer());
    //   add a serializer to use object.toString() while serializing
    module.addSerializer(ID.class, new ObjectStringSerializer<ID>());
   
    // register the module with the object-mapper
    mapper.registerModule(module);

    mapper.getJsonFactory();
View Full Code Here

import org.codehaus.jackson.map.module.SimpleModule;

public class IMetricSerializer {
    public ObjectMapper getObjectMapper() {
        ObjectMapper mapper = new ObjectMapper();
        SimpleModule metricModule = new SimpleModule("IMetricSerializerModule", new Version(1, 0, 0, null));

        metricModule.setMixInAnnotation(IMetric.class, IMetricMixin.class);
        metricModule.setMixInAnnotation(Locator.class, LocatorMixin.class);
        metricModule.setMixInAnnotation(PreaggregatedMetric.class, PreaggMetricMixin.class);
        metricModule.setMixInAnnotation(Rollup.class, RollupMixin.class);
        metricModule.setMixInAnnotation(BasicRollup.class, BasicRollupMixin.class);
        metricModule.setMixInAnnotation(AbstractRollupStat.class, AbstractRollupStatMixin.class);
        metricModule.setMixInAnnotation(GaugeRollup.class, GaugeRollupMixin.class);
        metricModule.setMixInAnnotation(TimerRollup.class, TimerRollupMixin.class);
        metricModule.setMixInAnnotation(TimerRollup.Percentile.class, PercentileMixin.class);

        metricModule.addSerializer(AbstractRollupStat.class, new AbstractRollupStatSerializer());
        metricModule.addDeserializer(Metric.class, new MetricDeserializer());
        metricModule.addDeserializer(GaugeRollup.class, new GaugeRollupDeserializer());

        mapper.setVisibility(JsonMethod.FIELD, JsonAutoDetect.Visibility.ANY);
        mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);

        mapper.registerModule(metricModule);
View Full Code Here

    com.clashinspector.DependencyService dependencyService = new com.clashinspector.DependencyService();
    ClashCollectResultWrapper clashCollectResultWrapper = new ClashCollectResultWrapper( dependencyService.getDependencyTree( mainArtifact, repositorySystemSession, repositorySystem, userParameterWrapper.getIncludedScopes(), userParameterWrapper.getExcludedScopes(), userParameterWrapper.getIncludeOptional() ) );


    ObjectMapper mapper = new ObjectMapper();
    SimpleModule module = new SimpleModule( "MyModule", new org.codehaus.jackson.Version( 1, 0, 0, null ) );

    module.addSerializer( Version.class, new VersionSerializer() );
    module.addSerializer( Project.class, new ProjectSerializerForDependencyNodeWrapper() );
    module.addSerializer( DependencyNodeWrapper.class, new DependencyNodeWrapperSerializer() );
    mapper.registerModule( module );


    String value = "";
    try {
View Full Code Here

    com.clashinspector.DependencyService dependencyService = new com.clashinspector.DependencyService();
    ClashCollectResultWrapper clashCollectResultWrapper = new ClashCollectResultWrapper( dependencyService.getDependencyTree( mainArtifact, repositorySystemSession, repositorySystem, userParameterWrapper.getIncludedScopes(), userParameterWrapper.getExcludedScopes(), userParameterWrapper.getIncludeOptional() ) );


    ObjectMapper mapper = new ObjectMapper();
    SimpleModule module = new SimpleModule( "MyModule", new org.codehaus.jackson.Version( 1, 0, 0, null ) );


    String value = "";
    try {


      ResponseObject responseObject = new ResponseObject();

      responseObject.setResult( clashCollectResultWrapper.getOuterClashesForSeverityLevel( clashSeverity ) );
      responseObject.setUserParameterWrapper( userParameterWrapper );


      module.addSerializer( Version.class, new VersionSerializer() );
      module.addSerializer( OuterVersionClash.class, new OuterVersionClashSerializer( clashSeverity ) );
      module.addSerializer( InnerVersionClash.class, new InnerVersionClashSerializer() );
      module.addSerializer( Project.class, new ProjectSerializerForDependencyNodeWrapper() );

      mapper.registerModule( module );

      value = mapper.writeValueAsString( responseObject );
View Full Code Here

  public static Module build() {

    Version version = new Version(1, 0, 0, null);

    SimpleModule module = new SimpleModule("values", version);

    //

    Class<DecimalValue> klazDecimal = DecimalValue.class;
    module.addSerializer(new DecimalValueSer(klazDecimal));
    module.addDeserializer(klazDecimal, new DecimalValueDes(klazDecimal));

    //

    Class<PriceValue> klazPrice = PriceValue.class;
    module.addSerializer(new PriceValueSer(klazPrice));
    module.addDeserializer(klazPrice, new PriceValueDes(klazPrice));

    //

    Class<SizeValue> klazSize = SizeValue.class;
    module.addSerializer(new SizeValueSer(klazSize));
    module.addDeserializer(klazSize, new SizeValueDes(klazSize));

    //

    Class<TextValue> klazText = TextValue.class;
    module.addSerializer(new TextValueSer(klazText));
    module.addDeserializer(klazText, new TextValueDes(klazText));

    //

    Class<TimeValue> klazTime = TimeValue.class;
    module.addSerializer(new TimeValueSer(klazTime));
    module.addDeserializer(klazTime, new TimeValueDes(klazTime));

    //

    return module;
View Full Code Here

import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.module.SimpleModule;

public class PointyObjectMapper extends ObjectMapper{
    public PointyObjectMapper() {
        SimpleModule module = new SimpleModule("JSONModule", new Version(2, 0, 0, null));
        module.addSerializer(Date.class, new DateSerializer());
        module.addDeserializer(Date.class, new DateDeserializer());
        //...
        this.registerModule(module);
    }
View Full Code Here

     * E.g. 21474836470 would be deserialized into an Integer as -10.
     * E.g. 92233720368547758080 would be deserialized into a Long as 0.
     */
    private static void applyNumericRangeBugfixes(ObjectMapper mapper) {
        // Create a custom module
        SimpleModule customModule = new SimpleModule("CustomModule", new Version(1, 0, 0, null));
        // Register a deserializer for Integer that overrides default buggy version
        customModule.addDeserializer(Integer.class, new IntegerDeserializer());
        customModule.addDeserializer(int.class, new IntegerDeserializer());
        // Register a deserializer for Long that overrides default buggy version
        customModule.addDeserializer(Long.class, new LongDeserializer());
        customModule.addDeserializer(long.class, new LongDeserializer());
        // Register a deserializer for Byte that overrides default buggy version
        customModule.addDeserializer(Byte.class, new ByteDeserializer());
        customModule.addDeserializer(byte.class, new ByteDeserializer());
        // Add the module to the mapper
        mapper.registerModule(customModule);
    }
View Full Code Here

TOP

Related Classes of org.codehaus.jackson.map.module.SimpleModule

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.