Version a = new Version("1.1"); Version b = new Version("1.1.1"); Version a = new Version("2.0"); Version b = new Version("1.9.9"); Version a = new Version("1.0"); Version b = new Version("1"); Version a = new Version("1"); Version b = null; versions.add(new Version("2")); versions.add(new Version("1.0.5")); versions.add(new Version("1.01.0")); versions.add(new Version("1.00.1")); Version a = new Version("2.06"); Version b = new Version("2.060");
ObjectMapper mapper = new ObjectMapper(); SimpleModule simpleModule = new SimpleModule("SimpleModule", new Version(1,0,0,null)); // simpleModule.addSerializer(new ItemSerializer()); simpleModule.addSerializer(Item.class, new ItemSerializer()); mapper.registerModule(simpleModule);
/** * Returns a {@code Version} object holding the version identifier in the * specified {@code String}. * * <p> * See {@link #Version(String)} for the format of the version string. * * <p> * This method performs a similar function as {@link #parseVersion(String)} * but has the static factory {@code valueOf(String)} method signature. * * @param version String representation of the version identifier. Leading * and trailing whitespace will be ignored. Must not be {@code null}. * @return A {@code Version} object representing the version identifier. If * {@code version} is the empty string then {@link #emptyVersion} * will be returned. * @throws IllegalArgumentException If {@code version} is improperly * formatted. * @since 1.8 */ public static Version valueOf(String version) { version = version.trim(); if (version.length() == 0) { return emptyVersion; } return new Version(version); }
LongJsonDeserializer deserializer = new LongJsonDeserializer(); SimpleModule module = new SimpleModule("LongDeserializerModule", new Version(1, 0, 0, null)); module.addDeserializer(Long.class, deserializer); ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(module);
new Version(1, 0, 0, null)); module.addDeserializer(Long.class, new LongJsonDeserializer());
} else { Version adjacent1 = new Version(left.getMajor(), left.getMinor(), left.getMicro(), left.getQualifier() + "-"); return adjacent1.compareTo(right) >= 0; if (rightClosed) { Version adjacent1 = new Version(left.getMajor(), left.getMinor(), left.getMicro(), left.getQualifier() + "-"); return adjacent1.equals(right); } else { Version adjacent2 = new Version(left.getMajor(), left.getMinor(), left.getMicro(), left.getQualifier() + "--"); return adjacent2.compareTo(right) >= 0;
public Object run() { String version = context .getProperty(Constants.FRAMEWORK_VERSION); return (version == null) ? Version.emptyVersion : new Version(version); } });
public class JSONMapper extends ObjectMapper { public JSONMapper() { SimpleModule module = new SimpleModule("JSONModule", new Version(2, 0, 0, null, null, null)); module.addSerializer(Date.class, new DateSerializer()); module.addDeserializer(Date.class, new DateDeserializer()); // Add more here ... registerModule(module); } }
.getProperty(Constants.FRAMEWORK_VERSION); return (version == null) ? Version.emptyVersion : new Version(version);
public PluginIdentification(final String symbolicName, final String version) { this.symbolicName = symbolicName; this.version = new Version(version); }
public class JacksonMixinModule extends SimpleModule { public JacksonMixinModule() { super("JacksonMixinModule", new Version(0, 1, 0, "SNAPSHOT")); } @Override public void setupModule(SetupContext context) { super.setupModule(context); context.setMixInAnnotations(Something.class, Mixin.class); context.setMixInAnnotations(Nested.class, NestedMixin.class); } }
public Version run() { String version = context .getProperty(Constants.FRAMEWORK_VERSION); return (version == null) ? Version.emptyVersion : new Version(version); } });
SimpleModule module = new SimpleModule("test", new Version(1, 0, 0, null)); module.addDeserializer(Map.class, new JsonDeserializer<Map>() { @Override public Map deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { return jp.readValueAs(HashMap.class); } @Override public Map getNullValue() { return new HashMap(); } }); mapper.registerModule(module);
public class MyCustomObjectMapper extends ObjectMapper { public MyCustomObjectMapper() { SimpleModule module = new SimpleModule("My Module", new Version(1, 0, 0, "SNAPSHOT")); module.addSerializer(new CustomSerializer()); module.addSerializer(new CustomSerializer2()); // etc this.registerModule(module); } }
/** * @see org.apache.sling.installer.api.tasks.TaskResource#getVersion() */ @Override public Version getVersion() { final String vInfo = (String)this.getAttribute(Constants.BUNDLE_VERSION); return (vInfo == null ? null : new Version(vInfo)); }
/** * {@inheritDoc} */ public Version getBundleVersion() { String value = this.contents.get(Constants.BUNDLE_VERSION); if (value != null) { return new Version(value); } else { return Version.emptyVersion; } }
/** * {@inheritDoc} */ public Version getVersion() { String value = getAttributes().get(Constants.VERSION_ATTRIBUTE); if (value != null) { return new Version(value); } else { return Version.emptyVersion; } }
private static Version readVersion(DataInputStream in) throws IOException { byte tag = in.readByte(); if (tag == NULL) return Version.emptyVersion; int majorComponent = in.readInt(); int minorComponent = in.readInt(); int serviceComponent = in.readInt(); String qualifierComponent = readString(in); return (Version) ObjectPool.intern(new Version(majorComponent, minorComponent, serviceComponent, qualifierComponent)); }
public OSGiJdbcDriver(BundleContext context, JdbcRegistry registry) { String versionString = (String) context.getBundle().getHeaders().get(Constants.BUNDLE_VERSION); Version version = new Version(versionString); majorVersion = version.getMajor(); minorVersion = version.getMinor(); this.registry = registry; }
ResteasyJacksonProvider resteasyJacksonProvider = new ResteasyJacksonProvider(); ObjectMapper mapper = new ObjectMapper(); SimpleModule myModule = new SimpleModule("myModule", new Version(1, 0, 0, null)); myModule.addSerializer(Custom.class, new CustomSerializer()); mapper.registerModule(myModule); resteasyJacksonProvider.setMapper(mapper); ResteasyClient client = new ResteasyClientBuilder().register(resteasyJacksonProvider).build();