/** * Property used to specify custom naming strategy. * * Configures value of {@code JSONB_PROPERTY_NAMING_STRATEGY} property. * * @param propertyNamingStrategy * Custom naming strategy which affects serialization and deserialization. * * @return This JsonbConfig instance. */ public final JsonbConfig withPropertyNamingStrategy(final PropertyNamingStrategy propertyNamingStrategy) { return setProperty(PROPERTY_NAMING_STRATEGY, propertyNamingStrategy); }
/** * Property used to specify property order strategy. * * Configures values of {@code JSONB_PROPERTY_ORDER_STRATEGY} property. * * @param propertyOrderStrategy * Predefined property order strategy which affects serialization. * * @return This JsonbConfig instance. */ public final JsonbConfig withPropertyOrderStrategy(final String propertyOrderStrategy) { return setProperty(PROPERTY_ORDER_STRATEGY, propertyOrderStrategy); }
/** * Property used to specify custom locale. * * @param locale * Locale, must not be null. * @return This JsonbConfig instance. */ public final JsonbConfig withLocale(final Locale locale) { return setProperty(LOCALE, locale); }
/** * Property used to specify custom locale. * * @param locale * Locale, must not be null. * @return This JsonbConfig instance. */ public final JsonbConfig withLocale(final Locale locale) { return setProperty(LOCALE, locale); }
/** * Property used to specify whether strict I-JSON serialization compliance should be enforced. * * Configures value of {@code STRICT_IJSON} property. * * @param enabled * True means data is serialized in strict compliance according to RFC 7493. * * @return This JsonbConfig instance. */ public final JsonbConfig withStrictIJSON(final Boolean enabled) { return setProperty(STRICT_IJSON, enabled); }
public final JsonbConfig withDeserializers(final JsonbDeserializer... deserializers) { return setProperty(DESERIALIZERS, deserializers); } }
public void setFailOnUnknownProperties(final boolean active) { config.setProperty("johnzon.fail-on-unknown-properties", active); customized = true; }
/** * Property used to specify custom naming strategy. * * Configures value of {@code JSONB_PROPERTY_NAMING_STRATEGY} property. * * @param propertyNamingStrategy * Predefined naming strategy which affects serialization and deserialization. * * @return This JsonbConfig instance. */ public final JsonbConfig withPropertyNamingStrategy(final String propertyNamingStrategy) { return setProperty(PROPERTY_NAMING_STRATEGY, propertyNamingStrategy); }
/** * Property used to specify custom property visibility strategy. * * Configures value of {@code PROPERTY_VISIBILITY_STRATEGY} property. * * @param propertyVisibilityStrategy * Custom property visibility strategy which affects serialization and deserialization. * * @return This JsonbConfig instance. */ public final JsonbConfig withPropertyVisibilityStrategy(final PropertyVisibilityStrategy propertyVisibilityStrategy) { return setProperty(PROPERTY_VISIBILITY_STRATEGY, propertyVisibilityStrategy); }
/** * Property used to specify custom binary data strategy. * * Configures value of {@code BINARY_DATA_STRATEGY} property. * * @param binaryDataStrategy * Custom binary data strategy which affects serialization and deserialization. * * @return This JsonbConfig instance. */ public final JsonbConfig withBinaryDataStrategy(final String binaryDataStrategy) { return setProperty(BINARY_DATA_STRATEGY, binaryDataStrategy); }
public void setFailOnUnknownProperties(final boolean active) { config.setProperty("johnzon.fail-on-unknown-properties", active); customized = true; }
public final JsonbConfig withLocale(final Locale locale) { return setProperty(LOCALE, locale); }
public final JsonbConfig withStrictIJSON(final Boolean enabled) { return setProperty(STRICT_IJSON, enabled); }
public final JsonbConfig withPropertyNamingStrategy(final String propertyNamingStrategy) { return setProperty(PROPERTY_NAMING_STRATEGY, propertyNamingStrategy); }
public final JsonbConfig withDateFormat(final String dateFormat, final Locale locale) { return setProperty(DATE_FORMAT, dateFormat).setProperty(LOCALE, locale != null ? locale : Locale.getDefault()); }
@SuppressWarnings("unchecked") private <T> void mergeProperties(final String propertyKey, final T[] values, final Class<T> tClass) { final Optional<Object> property = getProperty(propertyKey); if (!property.isPresent()) { setProperty(propertyKey, values); return; } T[] storedValues = (T[]) property.get(); T[] newValues = (T[]) Array.newInstance(tClass, storedValues.length + values.length); System.arraycopy(storedValues, 0, newValues, 0, storedValues.length); System.arraycopy(values, 0, newValues, storedValues.length, values.length); setProperty(propertyKey, newValues); } }
public void setInterfaceImplementationMapping(final Map<String, String> interfaceImplementationMapping) { final ClassLoader loader = Thread.currentThread().getContextClassLoader(); final Function<String, Class<?>> load = name -> { try { return loader.loadClass(name.trim()); } catch (final ClassNotFoundException e) { throw new IllegalArgumentException(e); } }; config.setProperty("johnzon.interfaceImplementationMapping", interfaceImplementationMapping.entrySet().stream() .collect(toMap(it -> load.apply(it.getKey()), it -> load.apply(it.getValue())))); customized = true; }
public void setOtherProperties(final String others) { final Properties properties = new Properties() {{ try { load(new StringReader(others)); } catch (final IOException e) { throw new IllegalArgumentException(e); } }}; properties.stringPropertyNames().forEach(k -> config.setProperty(k, properties.getProperty(k))); customized = true; }
public UiSpecService(final Client client) { this.client = client; this.jsonb = JsonbBuilder.create(new JsonbConfig().setProperty("johnzon.cdi.activated", false)); this.closeJsonb = true; }
@Override // for debug purposes, don't use it for anything else public String toString() { try (final Jsonb jsonb = JsonbBuilder .create(new JsonbConfig().withFormatting(true).setProperty("johnzon.cdi.activated", false))) { return new RecordConverters() .toType(this, JsonObject.class, () -> Json.createBuilderFactory(emptyMap()), JsonProvider::provider, () -> jsonb) .toString(); } catch (final Exception e) { return super.toString(); } }