
com.symphony.oss.models.fundmental.canon.NotificationEntity Maven / Gradle / Ivy
/**
* GENERATED CODE - DO NOT EDIT OR CHECK IN TO SOURCE CODE CONTROL
*
* Copyright 2020 Symphony Communication Services, LLC.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*----------------------------------------------------------------------------------------------------
* Generated from
* Input source file:/Users/bruce/symphony/git-SymphonyOSF/oss-models/target/checkout/fundamental-model/src/main/resources/canon/fundamental.json
* Template groupId org.symphonyoss.s2.canon
* artifactId canon-template-java
* Template name template/java/Object/_Entity.java.ftl
* At 2020-01-28 16:55:36 GMT
*----------------------------------------------------------------------------------------------------
*/
package com.symphony.oss.models.fundmental.canon;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;
import org.symphonyoss.s2.common.immutable.ImmutableByteArray;
import org.symphonyoss.s2.canon.runtime.IEntity;
import org.symphonyoss.s2.canon.runtime.IModelRegistry;
import org.symphonyoss.s2.canon.runtime.CanonRuntime;
import org.symphonyoss.s2.canon.runtime.Entity;
import org.symphonyoss.s2.canon.runtime.EntityBuilder;
import org.symphonyoss.s2.canon.runtime.EntityFactory;
import org.symphonyoss.s2.canon.runtime.IBuilderFactory;
import org.symphonyoss.s2.common.type.provider.IBooleanProvider;
import org.symphonyoss.s2.common.type.provider.IStringProvider;
import org.symphonyoss.s2.common.type.provider.IIntegerProvider;
import org.symphonyoss.s2.common.type.provider.ILongProvider;
import org.symphonyoss.s2.common.type.provider.IFloatProvider;
import org.symphonyoss.s2.common.type.provider.IDoubleProvider;
import org.symphonyoss.s2.common.type.provider.IImmutableByteArrayProvider;
import org.symphonyoss.s2.common.dom.json.IJsonDomNode;
import org.symphonyoss.s2.common.dom.json.IImmutableJsonDomNode;
import org.symphonyoss.s2.common.dom.json.ImmutableJsonList;
import org.symphonyoss.s2.common.dom.json.ImmutableJsonSet;
import org.symphonyoss.s2.common.dom.json.ImmutableJsonObject;
import org.symphonyoss.s2.common.dom.json.MutableJsonList;
import org.symphonyoss.s2.common.dom.json.MutableJsonSet;
import org.symphonyoss.s2.common.dom.json.MutableJsonObject;
import org.symphonyoss.s2.common.dom.json.JsonArray;
import org.symphonyoss.s2.common.dom.json.JsonList;
import org.symphonyoss.s2.common.dom.json.JsonSet;
import java.util.HashSet;
import java.util.List;
import java.util.LinkedList;
import java.util.Set;
import java.util.Iterator;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import java.util.List;
import java.util.LinkedList;
import com.google.common.collect.ImmutableList;
import org.symphonyoss.s2.common.immutable.ImmutableByteArray;
import org.symphonyoss.s2.common.hash.Hash;
import java.time.Instant;
import com.symphony.oss.models.core.canon.facade.InstantBuilder;
import com.symphony.oss.models.fundamental.canon.facade.*;
import com.symphony.oss.models.crypto.canon.facade.*;
import com.symphony.oss.models.crypto.canon.*;
import com.symphony.oss.models.core.canon.facade.*;
import com.symphony.oss.models.core.canon.*;
/**
* Object ObjectSchema(Notification)
*
* This is not a persisted object it exists only on a pub sub topic.
* Generated from ObjectSchema(Notification) at #/components/schemas/Notification
*/
@Immutable
@SuppressWarnings("unused")
public abstract class NotificationEntity extends ObjectPayload
implements INotification, IFundamentalModelEntity
{
/** Type ID */
public static final String TYPE_ID = "com.symphony.s2.model.fundamental.Notification";
/** Type version */
public static final String TYPE_VERSION = "1.0";
/** Type major version */
public static final Integer TYPE_MAJOR_VERSION = 1;
/** Type minor version */
public static final Integer TYPE_MINOR_VERSION = 0;
/** Factory instance */
public static final Factory FACTORY = new Factory();
/**
* Builder factory instance
*
* @deprecated use new Notification.Builder()
or new Notification.Builder(INotificationEntity)
*/
@Deprecated
public static final IBuilderFactory BUILDER = new BuilderFactory();
private final ImmutableSet unknownKeys_;
private final Set _distributionList_;
private final Instant _expirationDate_;
private final BroadcastType _broadcast_;
private final String _conflationId_;
private final Hash _contextHash_;
private final Hash _traceContextHash_;
private final Instant _notificationDate_;
private final Hash _payloadBaseHash_;
private final Hash _payloadPrevHash_;
private final Hash _payloadHash_;
private final IFundamentalId _payloadId_;
private final IFundamentalObject _payload_;
private final Hash _legacyIdHash_;
private final Hash _referencedLegacyIdHash_;
private final Integer _sequence_;
private final Boolean _final_;
private final Hash _subscriptionHash_;
private final Boolean _initialVersion_;
/**
* Constructor from builder.
*
* @param builder A mutable builder containing all values.
*/
public NotificationEntity(Notification.AbstractNotificationBuilder,?> builder)
{
super(builder);
_distributionList_ = ImmutableSet.copyOf(builder.getDistributionList());
_expirationDate_ = builder.getExpirationDate();
_broadcast_ = builder.getBroadcast();
_conflationId_ = builder.getConflationId();
_contextHash_ = builder.getContextHash();
_traceContextHash_ = builder.getTraceContextHash();
_notificationDate_ = builder.getNotificationDate();
_payloadBaseHash_ = builder.getPayloadBaseHash();
_payloadPrevHash_ = builder.getPayloadPrevHash();
_payloadHash_ = builder.getPayloadHash();
if(_payloadHash_ == null)
throw new IllegalArgumentException("payloadHash is required.");
_payloadId_ = builder.getPayloadId();
_payload_ = builder.getPayload();
_legacyIdHash_ = builder.getLegacyIdHash();
_referencedLegacyIdHash_ = builder.getReferencedLegacyIdHash();
_sequence_ = builder.getSequence();
_final_ = builder.getFinal();
_subscriptionHash_ = builder.getSubscriptionHash();
_initialVersion_ = builder.getInitialVersion();
unknownKeys_ = ImmutableSet.of();
}
/**
* Set the _type attribute of the given mutable JSON object to the type ID of this type if it is null and
* return an immutable copy.
*
* @param mutableJsonObject A mutable JSON Object.
*
* @return An immutable copy of the given object with the _type attribute set.
*/
public static ImmutableJsonObject setType(MutableJsonObject mutableJsonObject)
{
if(mutableJsonObject.get(CanonRuntime.JSON_TYPE) == null)
mutableJsonObject.addIfNotNull(CanonRuntime.JSON_TYPE, TYPE_ID);
return mutableJsonObject.immutify();
}
/**
* Constructor from mutable JSON object.
*
* @param mutableJsonObject A mutable JSON object containing the serialized form of the object.
* @param modelRegistry A model registry to use to deserialize any nested objects.
*/
public NotificationEntity(MutableJsonObject mutableJsonObject, IModelRegistry modelRegistry)
{
this(setType(mutableJsonObject), modelRegistry);
}
/**
* Constructor from serialised form.
*
* @param jsonObject An immutable JSON object containing the serialized form of the object.
* @param modelRegistry A model registry to use to deserialize any nested objects.
*/
public NotificationEntity(ImmutableJsonObject jsonObject, IModelRegistry modelRegistry)
{
super(jsonObject, modelRegistry);
if(jsonObject == null)
throw new IllegalArgumentException("jsonObject is required");
Set keySet = new HashSet<>(super.getCanonUnknownKeys());
if(keySet.remove("distributionList"))
{
IJsonDomNode node = jsonObject.get("distributionList");
if(node instanceof JsonArray)
{
Set list = new HashSet<>();
for(IJsonDomNode itemNode : ((JsonArray>)node))
{
if(itemNode instanceof IImmutableByteArrayProvider)
{
ImmutableByteArray value = ((IImmutableByteArrayProvider)itemNode).asImmutableByteArray();
list.add(Hash.build(value));
}
}
_distributionList_ = ImmutableSet.copyOf(list);
}
else
{
throw new IllegalArgumentException("distributionList must be an array not " + node.getClass().getName());
}
}
else
{
_distributionList_ = null;
}
if(keySet.remove("expirationDate"))
{
IJsonDomNode node = jsonObject.get("expirationDate");
if(node instanceof IStringProvider)
{
String value = ((IStringProvider)node).asString();
try
{
_expirationDate_ = InstantBuilder.build(value);
}
catch(RuntimeException e)
{
throw new IllegalArgumentException("Value \"" + value + "\" for expirationDate is not a valid value", e);
}
}
else
{
throw new IllegalArgumentException("expirationDate must be an instance of String not " + node.getClass().getName());
}
}
else
{
_expirationDate_ = null;
}
if(keySet.remove("broadcast"))
{
IJsonDomNode node = jsonObject.get("broadcast");
if(node instanceof IStringProvider)
{
String value = ((IStringProvider)node).asString();
try
{
_broadcast_ = BroadcastType.valueOf(value);
}
catch(RuntimeException e)
{
throw new IllegalArgumentException("Value \"" + value + "\" for broadcast is not a valid value", e);
}
}
else
{
throw new IllegalArgumentException("broadcast must be an instance of String not " + node.getClass().getName());
}
}
else
{
_broadcast_ = null;
}
if(keySet.remove("conflationId"))
{
IJsonDomNode node = jsonObject.get("conflationId");
if(node instanceof IStringProvider)
{
String value = ((IStringProvider)node).asString();
_conflationId_ = value;
}
else
{
throw new IllegalArgumentException("conflationId must be an instance of String not " + node.getClass().getName());
}
}
else
{
_conflationId_ = null;
}
if(keySet.remove("contextHash"))
{
IJsonDomNode node = jsonObject.get("contextHash");
if(node instanceof IImmutableByteArrayProvider)
{
ImmutableByteArray value = ((IImmutableByteArrayProvider)node).asImmutableByteArray();
try
{
_contextHash_ = Hash.build(value);
}
catch(RuntimeException e)
{
throw new IllegalArgumentException("Value \"" + value + "\" for contextHash is not a valid value", e);
}
}
else
{
throw new IllegalArgumentException("contextHash must be an instance of ImmutableByteArray not " + node.getClass().getName());
}
}
else
{
_contextHash_ = null;
}
if(keySet.remove("traceContextHash"))
{
IJsonDomNode node = jsonObject.get("traceContextHash");
if(node instanceof IImmutableByteArrayProvider)
{
ImmutableByteArray value = ((IImmutableByteArrayProvider)node).asImmutableByteArray();
try
{
_traceContextHash_ = Hash.build(value);
}
catch(RuntimeException e)
{
throw new IllegalArgumentException("Value \"" + value + "\" for traceContextHash is not a valid value", e);
}
}
else
{
throw new IllegalArgumentException("traceContextHash must be an instance of ImmutableByteArray not " + node.getClass().getName());
}
}
else
{
_traceContextHash_ = null;
}
if(keySet.remove("notificationDate"))
{
IJsonDomNode node = jsonObject.get("notificationDate");
if(node instanceof IStringProvider)
{
String value = ((IStringProvider)node).asString();
try
{
_notificationDate_ = InstantBuilder.build(value);
}
catch(RuntimeException e)
{
throw new IllegalArgumentException("Value \"" + value + "\" for notificationDate is not a valid value", e);
}
}
else
{
throw new IllegalArgumentException("notificationDate must be an instance of String not " + node.getClass().getName());
}
}
else
{
_notificationDate_ = null;
}
if(keySet.remove("payloadBaseHash"))
{
IJsonDomNode node = jsonObject.get("payloadBaseHash");
if(node instanceof IImmutableByteArrayProvider)
{
ImmutableByteArray value = ((IImmutableByteArrayProvider)node).asImmutableByteArray();
try
{
_payloadBaseHash_ = Hash.build(value);
}
catch(RuntimeException e)
{
throw new IllegalArgumentException("Value \"" + value + "\" for payloadBaseHash is not a valid value", e);
}
}
else
{
throw new IllegalArgumentException("payloadBaseHash must be an instance of ImmutableByteArray not " + node.getClass().getName());
}
}
else
{
_payloadBaseHash_ = null;
}
if(keySet.remove("payloadPrevHash"))
{
IJsonDomNode node = jsonObject.get("payloadPrevHash");
if(node instanceof IImmutableByteArrayProvider)
{
ImmutableByteArray value = ((IImmutableByteArrayProvider)node).asImmutableByteArray();
try
{
_payloadPrevHash_ = Hash.build(value);
}
catch(RuntimeException e)
{
throw new IllegalArgumentException("Value \"" + value + "\" for payloadPrevHash is not a valid value", e);
}
}
else
{
throw new IllegalArgumentException("payloadPrevHash must be an instance of ImmutableByteArray not " + node.getClass().getName());
}
}
else
{
_payloadPrevHash_ = null;
}
if(keySet.remove("payloadHash"))
{
IJsonDomNode node = jsonObject.get("payloadHash");
if(node instanceof IImmutableByteArrayProvider)
{
ImmutableByteArray value = ((IImmutableByteArrayProvider)node).asImmutableByteArray();
try
{
_payloadHash_ = Hash.build(value);
}
catch(RuntimeException e)
{
throw new IllegalArgumentException("Value \"" + value + "\" for payloadHash is not a valid value", e);
}
}
else
{
throw new IllegalArgumentException("payloadHash must be an instance of ImmutableByteArray not " + node.getClass().getName());
}
}
else
{
throw new IllegalArgumentException("payloadHash is required.");
}
if(keySet.remove("payloadId"))
{
IJsonDomNode node = jsonObject.get("payloadId");
if(node instanceof ImmutableJsonObject)
{
_payloadId_ = modelRegistry.newInstance((ImmutableJsonObject)node, FundamentalId.TYPE_ID, IFundamentalId.class);
}
else
{
throw new IllegalArgumentException("payloadId must be an Object node not " + node.getClass().getName());
}
}
else
{
_payloadId_ = null;
}
if(keySet.remove("payload"))
{
IJsonDomNode node = jsonObject.get("payload");
if(node instanceof ImmutableJsonObject)
{
_payload_ = modelRegistry.newInstance((ImmutableJsonObject)node, FundamentalObject.TYPE_ID, IFundamentalObject.class);
}
else
{
throw new IllegalArgumentException("payload must be an Object node not " + node.getClass().getName());
}
}
else
{
_payload_ = null;
}
if(keySet.remove("legacyIdHash"))
{
IJsonDomNode node = jsonObject.get("legacyIdHash");
if(node instanceof IImmutableByteArrayProvider)
{
ImmutableByteArray value = ((IImmutableByteArrayProvider)node).asImmutableByteArray();
try
{
_legacyIdHash_ = Hash.build(value);
}
catch(RuntimeException e)
{
throw new IllegalArgumentException("Value \"" + value + "\" for legacyIdHash is not a valid value", e);
}
}
else
{
throw new IllegalArgumentException("legacyIdHash must be an instance of ImmutableByteArray not " + node.getClass().getName());
}
}
else
{
_legacyIdHash_ = null;
}
if(keySet.remove("referencedLegacyIdHash"))
{
IJsonDomNode node = jsonObject.get("referencedLegacyIdHash");
if(node instanceof IImmutableByteArrayProvider)
{
ImmutableByteArray value = ((IImmutableByteArrayProvider)node).asImmutableByteArray();
try
{
_referencedLegacyIdHash_ = Hash.build(value);
}
catch(RuntimeException e)
{
throw new IllegalArgumentException("Value \"" + value + "\" for referencedLegacyIdHash is not a valid value", e);
}
}
else
{
throw new IllegalArgumentException("referencedLegacyIdHash must be an instance of ImmutableByteArray not " + node.getClass().getName());
}
}
else
{
_referencedLegacyIdHash_ = null;
}
if(keySet.remove("sequence"))
{
IJsonDomNode node = jsonObject.get("sequence");
if(node instanceof IIntegerProvider)
{
Integer value = ((IIntegerProvider)node).asInteger();
_sequence_ = value;
}
else
{
throw new IllegalArgumentException("sequence must be an instance of Integer not " + node.getClass().getName());
}
}
else
{
_sequence_ = null;
}
if(keySet.remove("final"))
{
IJsonDomNode node = jsonObject.get("final");
if(node instanceof IBooleanProvider)
{
Boolean value = ((IBooleanProvider)node).asBoolean();
_final_ = value;
}
else
{
throw new IllegalArgumentException("final must be an instance of Boolean not " + node.getClass().getName());
}
}
else
{
_final_ = null;
}
if(keySet.remove("subscriptionHash"))
{
IJsonDomNode node = jsonObject.get("subscriptionHash");
if(node instanceof IImmutableByteArrayProvider)
{
ImmutableByteArray value = ((IImmutableByteArrayProvider)node).asImmutableByteArray();
try
{
_subscriptionHash_ = Hash.build(value);
}
catch(RuntimeException e)
{
throw new IllegalArgumentException("Value \"" + value + "\" for subscriptionHash is not a valid value", e);
}
}
else
{
throw new IllegalArgumentException("subscriptionHash must be an instance of ImmutableByteArray not " + node.getClass().getName());
}
}
else
{
_subscriptionHash_ = null;
}
if(keySet.remove("initialVersion"))
{
IJsonDomNode node = jsonObject.get("initialVersion");
if(node instanceof IBooleanProvider)
{
Boolean value = ((IBooleanProvider)node).asBoolean();
_initialVersion_ = value;
}
else
{
throw new IllegalArgumentException("initialVersion must be an instance of Boolean not " + node.getClass().getName());
}
}
else
{
_initialVersion_ = null;
}
unknownKeys_ = ImmutableSet.copyOf(keySet);
}
/**
* Copy constructor.
*
* @param other Another instance from which all attributes are to be copied.
*/
public NotificationEntity(INotification other)
{
super(other);
_distributionList_ = other.getDistributionList();
_expirationDate_ = other.getExpirationDate();
_broadcast_ = other.getBroadcast();
_conflationId_ = other.getConflationId();
_contextHash_ = other.getContextHash();
_traceContextHash_ = other.getTraceContextHash();
_notificationDate_ = other.getNotificationDate();
_payloadBaseHash_ = other.getPayloadBaseHash();
_payloadPrevHash_ = other.getPayloadPrevHash();
_payloadHash_ = other.getPayloadHash();
_payloadId_ = other.getPayloadId();
_payload_ = other.getPayload();
_legacyIdHash_ = other.getLegacyIdHash();
_referencedLegacyIdHash_ = other.getReferencedLegacyIdHash();
_sequence_ = other.getSequence();
_final_ = other.getFinal();
_subscriptionHash_ = other.getSubscriptionHash();
_initialVersion_ = other.getInitialVersion();
unknownKeys_ = other.getCanonUnknownKeys();
}
@Override
public ImmutableSet getCanonUnknownKeys()
{
return unknownKeys_;
}
@Override
public Set getDistributionList()
{
return _distributionList_;
}
@Override
public Instant getExpirationDate()
{
return _expirationDate_;
}
@Override
public BroadcastType getBroadcast()
{
return _broadcast_;
}
@Override
public String getConflationId()
{
return _conflationId_;
}
@Override
public Hash getContextHash()
{
return _contextHash_;
}
@Override
public Hash getTraceContextHash()
{
return _traceContextHash_;
}
@Override
public Instant getNotificationDate()
{
return _notificationDate_;
}
@Override
public Hash getPayloadBaseHash()
{
return _payloadBaseHash_;
}
@Override
public Hash getPayloadPrevHash()
{
return _payloadPrevHash_;
}
@Override
public Hash getPayloadHash()
{
return _payloadHash_;
}
@Override
public IFundamentalId getPayloadId()
{
return _payloadId_;
}
@Override
public IFundamentalObject getPayload()
{
return _payload_;
}
@Override
public Hash getLegacyIdHash()
{
return _legacyIdHash_;
}
@Override
public Hash getReferencedLegacyIdHash()
{
return _referencedLegacyIdHash_;
}
@Override
public Integer getSequence()
{
return _sequence_;
}
@Override
public Boolean getFinal()
{
return _final_;
}
@Override
public Hash getSubscriptionHash()
{
return _subscriptionHash_;
}
@Override
public Boolean getInitialVersion()
{
return _initialVersion_;
}
@Override
public boolean equals(Object obj)
{
if(obj instanceof NotificationEntity)
return toString().equals(((NotificationEntity)obj).toString());
return false;
}
/**
* Factory class for Notification.
*/
public static class Factory extends EntityFactory
{
protected Factory()
{
super(INotification.class, INotificationEntity.class);
}
/**
* Return the type identifier (_type JSON attribute) for entities created by this factory.
*
* @return The type identifier for entities created by this factory.
*/
@Override
public String getCanonType()
{
return TYPE_ID;
}
/**
* Return the type version (_version JSON attribute) for entities created by this factory.
*
* @return The type version for entities created by this factory.
*/
public String getCanonVersion()
{
return TYPE_VERSION;
}
/**
* Return the major type version for entities created by this factory.
*
* @return The major type version for entities created by this factory.
*/
public @Nullable Integer getCanonMajorVersion()
{
return TYPE_MAJOR_VERSION;
}
/**
* Return the minjor type version for entities created by this factory.
*
* @return The minor type version for entities created by this factory.
*/
public @Nullable Integer getCanonMinorVersion()
{
return TYPE_MINOR_VERSION;
}
/**
* Return a new entity instance created from the given JSON serialization.
*
* @param jsonObject The JSON serialized form of the required entity.
* @param modelRegistry A model registry to use to deserialize any nested objects.
*
* @return An instance of the entity represented by the given serialized form.
*
* @throws IllegalArgumentException If the given JSON is not valid.
*/
@Override
public INotification newInstance(ImmutableJsonObject jsonObject, IModelRegistry modelRegistry)
{
return new Notification(jsonObject, modelRegistry);
}
/**
* Return a new entity instance created from the given builder instance.
* This is used to construct an entity from its builder as the builder also
* implements the interface of the entity.
*
* @param builder a builder containing values of all fields for the required entity.
*
* @return An instance of the entity represented by the given values.
*
* @throws IllegalArgumentException If the given values are not valid.
*/
public INotification newInstance(Builder builder)
{
return new Notification(builder);
}
}
/**
* Builder factory
*
* @deprecated use new Notification.Builder()
or new Notification.Builder(INotificationEntity)
*/
@Deprecated
private static class BuilderFactory implements IBuilderFactory
{
/**
* @deprecated use new Notification.Builder()
*/
@Deprecated
@Override
public Builder newInstance()
{
return new Builder();
}
/**
* @deprecated use new Notification.Builder(INotificationEntity)
*/
@Deprecated
@Override
public Builder newInstance(INotificationEntity initial)
{
return new Builder(initial);
}
}
/**
* Builder for Notification
*
* Created by calling BUILDER.newInstance();
*
*/
public static class Builder extends Notification.AbstractNotificationBuilder
{
/**
* Constructor.
*/
public Builder()
{
super(Builder.class);
}
/**
* Constructor initialised from another object instance.
*
* @param initial An instance of the built type from which values are to be initialised.
*/
public Builder(INotificationEntity initial)
{
super(Builder.class, initial);
}
@Override
protected INotification construct()
{
return new Notification(this);
}
}
/**
* Abstract builder for Notification. If there are sub-classes of this type then their builders sub-class this builder.
*
* @param The concrete type of the builder, used for fluent methods.
* @param The concrete type of the built object.
*/
public static abstract class AbstractNotificationBuilder, T extends INotificationEntity>
extends ObjectPayload.AbstractObjectPayloadBuilder
{
protected Set _distributionList_ = new HashSet<>();
protected Instant _expirationDate_;
protected BroadcastType _broadcast_;
protected String _conflationId_;
protected Hash _contextHash_;
protected Hash _traceContextHash_;
protected Instant _notificationDate_;
protected Hash _payloadBaseHash_;
protected Hash _payloadPrevHash_;
protected Hash _payloadHash_;
protected IFundamentalId _payloadId_;
protected IFundamentalObject _payload_;
protected Hash _legacyIdHash_;
protected Hash _referencedLegacyIdHash_;
protected Integer _sequence_;
protected Boolean _final_;
protected Hash _subscriptionHash_;
protected Boolean _initialVersion_;
protected AbstractNotificationBuilder(Class type)
{
super(type);
}
protected AbstractNotificationBuilder(Class type, INotificationEntity initial)
{
super(type, initial);
_distributionList_.addAll(initial.getDistributionList());
_expirationDate_ = initial.getExpirationDate();
_broadcast_ = initial.getBroadcast();
_conflationId_ = initial.getConflationId();
_contextHash_ = initial.getContextHash();
_traceContextHash_ = initial.getTraceContextHash();
_notificationDate_ = initial.getNotificationDate();
_payloadBaseHash_ = initial.getPayloadBaseHash();
_payloadPrevHash_ = initial.getPayloadPrevHash();
_payloadHash_ = initial.getPayloadHash();
_payloadId_ = initial.getPayloadId();
_payload_ = initial.getPayload();
_legacyIdHash_ = initial.getLegacyIdHash();
_referencedLegacyIdHash_ = initial.getReferencedLegacyIdHash();
_sequence_ = initial.getSequence();
_final_ = initial.getFinal();
_subscriptionHash_ = initial.getSubscriptionHash();
_initialVersion_ = initial.getInitialVersion();
}
public B withValues(ImmutableJsonObject jsonObject, boolean ignoreValidation, IModelRegistry modelRegistry)
{
super.withValues(jsonObject, ignoreValidation, modelRegistry);
if(jsonObject.containsKey("distributionList"))
{
IJsonDomNode node = jsonObject.get("distributionList");
if(node instanceof JsonArray)
{
Set list = new HashSet<>();
for(IJsonDomNode itemNode : ((JsonArray>)node))
{
if(itemNode instanceof IImmutableByteArrayProvider)
{
ImmutableByteArray value = ((IImmutableByteArrayProvider)itemNode).asImmutableByteArray();
list.add(Hash.build(value));
}
}
_distributionList_ = ImmutableSet.copyOf(list);
}
else if(!ignoreValidation)
{
throw new IllegalArgumentException("distributionList must be an array not " + node.getClass().getName());
}
}
if(jsonObject.containsKey("expirationDate"))
{
IJsonDomNode node = jsonObject.get("expirationDate");
if(node instanceof IStringProvider)
{
String value = ((IStringProvider)node).asString();
try
{
_expirationDate_ = InstantBuilder.build(value);
}
catch(RuntimeException e)
{
if(!ignoreValidation) throw new IllegalArgumentException("Value \"" + value + "\" for expirationDate is not a valid value", e);
}
}
else if(!ignoreValidation)
{
throw new IllegalArgumentException("expirationDate must be an instance of String not " + node.getClass().getName());
}
}
if(jsonObject.containsKey("broadcast"))
{
IJsonDomNode node = jsonObject.get("broadcast");
if(node instanceof IStringProvider)
{
String value = ((IStringProvider)node).asString();
try
{
_broadcast_ = BroadcastType.valueOf(value);
}
catch(RuntimeException e)
{
if(!ignoreValidation) throw new IllegalArgumentException("Value \"" + value + "\" for broadcast is not a valid value", e);
}
}
else if(!ignoreValidation)
{
throw new IllegalArgumentException("broadcast must be an instance of String not " + node.getClass().getName());
}
}
if(jsonObject.containsKey("conflationId"))
{
IJsonDomNode node = jsonObject.get("conflationId");
if(node instanceof IStringProvider)
{
String value = ((IStringProvider)node).asString();
_conflationId_ = value;
}
else if(!ignoreValidation)
{
throw new IllegalArgumentException("conflationId must be an instance of String not " + node.getClass().getName());
}
}
if(jsonObject.containsKey("contextHash"))
{
IJsonDomNode node = jsonObject.get("contextHash");
if(node instanceof IImmutableByteArrayProvider)
{
ImmutableByteArray value = ((IImmutableByteArrayProvider)node).asImmutableByteArray();
try
{
_contextHash_ = Hash.build(value);
}
catch(RuntimeException e)
{
if(!ignoreValidation) throw new IllegalArgumentException("Value \"" + value + "\" for contextHash is not a valid value", e);
}
}
else if(!ignoreValidation)
{
throw new IllegalArgumentException("contextHash must be an instance of ImmutableByteArray not " + node.getClass().getName());
}
}
if(jsonObject.containsKey("traceContextHash"))
{
IJsonDomNode node = jsonObject.get("traceContextHash");
if(node instanceof IImmutableByteArrayProvider)
{
ImmutableByteArray value = ((IImmutableByteArrayProvider)node).asImmutableByteArray();
try
{
_traceContextHash_ = Hash.build(value);
}
catch(RuntimeException e)
{
if(!ignoreValidation) throw new IllegalArgumentException("Value \"" + value + "\" for traceContextHash is not a valid value", e);
}
}
else if(!ignoreValidation)
{
throw new IllegalArgumentException("traceContextHash must be an instance of ImmutableByteArray not " + node.getClass().getName());
}
}
if(jsonObject.containsKey("notificationDate"))
{
IJsonDomNode node = jsonObject.get("notificationDate");
if(node instanceof IStringProvider)
{
String value = ((IStringProvider)node).asString();
try
{
_notificationDate_ = InstantBuilder.build(value);
}
catch(RuntimeException e)
{
if(!ignoreValidation) throw new IllegalArgumentException("Value \"" + value + "\" for notificationDate is not a valid value", e);
}
}
else if(!ignoreValidation)
{
throw new IllegalArgumentException("notificationDate must be an instance of String not " + node.getClass().getName());
}
}
if(jsonObject.containsKey("payloadBaseHash"))
{
IJsonDomNode node = jsonObject.get("payloadBaseHash");
if(node instanceof IImmutableByteArrayProvider)
{
ImmutableByteArray value = ((IImmutableByteArrayProvider)node).asImmutableByteArray();
try
{
_payloadBaseHash_ = Hash.build(value);
}
catch(RuntimeException e)
{
if(!ignoreValidation) throw new IllegalArgumentException("Value \"" + value + "\" for payloadBaseHash is not a valid value", e);
}
}
else if(!ignoreValidation)
{
throw new IllegalArgumentException("payloadBaseHash must be an instance of ImmutableByteArray not " + node.getClass().getName());
}
}
if(jsonObject.containsKey("payloadPrevHash"))
{
IJsonDomNode node = jsonObject.get("payloadPrevHash");
if(node instanceof IImmutableByteArrayProvider)
{
ImmutableByteArray value = ((IImmutableByteArrayProvider)node).asImmutableByteArray();
try
{
_payloadPrevHash_ = Hash.build(value);
}
catch(RuntimeException e)
{
if(!ignoreValidation) throw new IllegalArgumentException("Value \"" + value + "\" for payloadPrevHash is not a valid value", e);
}
}
else if(!ignoreValidation)
{
throw new IllegalArgumentException("payloadPrevHash must be an instance of ImmutableByteArray not " + node.getClass().getName());
}
}
if(jsonObject.containsKey("payloadHash"))
{
IJsonDomNode node = jsonObject.get("payloadHash");
if(node instanceof IImmutableByteArrayProvider)
{
ImmutableByteArray value = ((IImmutableByteArrayProvider)node).asImmutableByteArray();
try
{
_payloadHash_ = Hash.build(value);
}
catch(RuntimeException e)
{
if(!ignoreValidation) throw new IllegalArgumentException("Value \"" + value + "\" for payloadHash is not a valid value", e);
}
}
else if(!ignoreValidation)
{
throw new IllegalArgumentException("payloadHash must be an instance of ImmutableByteArray not " + node.getClass().getName());
}
}
if(jsonObject.containsKey("payloadId"))
{
IJsonDomNode node = jsonObject.get("payloadId");
if(node instanceof ImmutableJsonObject)
{
_payloadId_ = modelRegistry.newInstance((ImmutableJsonObject)node, FundamentalId.TYPE_ID, IFundamentalId.class);
}
else if(!ignoreValidation)
{
throw new IllegalArgumentException("payloadId must be an Object node not " + node.getClass().getName());
}
}
if(jsonObject.containsKey("payload"))
{
IJsonDomNode node = jsonObject.get("payload");
if(node instanceof ImmutableJsonObject)
{
_payload_ = modelRegistry.newInstance((ImmutableJsonObject)node, FundamentalObject.TYPE_ID, IFundamentalObject.class);
}
else if(!ignoreValidation)
{
throw new IllegalArgumentException("payload must be an Object node not " + node.getClass().getName());
}
}
if(jsonObject.containsKey("legacyIdHash"))
{
IJsonDomNode node = jsonObject.get("legacyIdHash");
if(node instanceof IImmutableByteArrayProvider)
{
ImmutableByteArray value = ((IImmutableByteArrayProvider)node).asImmutableByteArray();
try
{
_legacyIdHash_ = Hash.build(value);
}
catch(RuntimeException e)
{
if(!ignoreValidation) throw new IllegalArgumentException("Value \"" + value + "\" for legacyIdHash is not a valid value", e);
}
}
else if(!ignoreValidation)
{
throw new IllegalArgumentException("legacyIdHash must be an instance of ImmutableByteArray not " + node.getClass().getName());
}
}
if(jsonObject.containsKey("referencedLegacyIdHash"))
{
IJsonDomNode node = jsonObject.get("referencedLegacyIdHash");
if(node instanceof IImmutableByteArrayProvider)
{
ImmutableByteArray value = ((IImmutableByteArrayProvider)node).asImmutableByteArray();
try
{
_referencedLegacyIdHash_ = Hash.build(value);
}
catch(RuntimeException e)
{
if(!ignoreValidation) throw new IllegalArgumentException("Value \"" + value + "\" for referencedLegacyIdHash is not a valid value", e);
}
}
else if(!ignoreValidation)
{
throw new IllegalArgumentException("referencedLegacyIdHash must be an instance of ImmutableByteArray not " + node.getClass().getName());
}
}
if(jsonObject.containsKey("sequence"))
{
IJsonDomNode node = jsonObject.get("sequence");
if(node instanceof IIntegerProvider)
{
Integer value = ((IIntegerProvider)node).asInteger();
_sequence_ = value;
}
else if(!ignoreValidation)
{
throw new IllegalArgumentException("sequence must be an instance of Integer not " + node.getClass().getName());
}
}
if(jsonObject.containsKey("final"))
{
IJsonDomNode node = jsonObject.get("final");
if(node instanceof IBooleanProvider)
{
Boolean value = ((IBooleanProvider)node).asBoolean();
_final_ = value;
}
else if(!ignoreValidation)
{
throw new IllegalArgumentException("final must be an instance of Boolean not " + node.getClass().getName());
}
}
if(jsonObject.containsKey("subscriptionHash"))
{
IJsonDomNode node = jsonObject.get("subscriptionHash");
if(node instanceof IImmutableByteArrayProvider)
{
ImmutableByteArray value = ((IImmutableByteArrayProvider)node).asImmutableByteArray();
try
{
_subscriptionHash_ = Hash.build(value);
}
catch(RuntimeException e)
{
if(!ignoreValidation) throw new IllegalArgumentException("Value \"" + value + "\" for subscriptionHash is not a valid value", e);
}
}
else if(!ignoreValidation)
{
throw new IllegalArgumentException("subscriptionHash must be an instance of ImmutableByteArray not " + node.getClass().getName());
}
}
if(jsonObject.containsKey("initialVersion"))
{
IJsonDomNode node = jsonObject.get("initialVersion");
if(node instanceof IBooleanProvider)
{
Boolean value = ((IBooleanProvider)node).asBoolean();
_initialVersion_ = value;
}
else if(!ignoreValidation)
{
throw new IllegalArgumentException("initialVersion must be an instance of Boolean not " + node.getClass().getName());
}
}
return self();
}
public void populateAllFields(List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy