/** * Returns an unmodifiable wrapper around the message. When accessing structures or types of the * {@link UnmodifiableMessage}, they will be unmodifiable as well. Copying these message parts into a regular * message should therefore be done using {@link ca.uhn.hl7v2.util.DeepCopy}. * * @param msg message to be wrapped * @return unmodifiable message wrapper */ public static Message unmodifiableMessage(Message msg) { return isUnmodifiable(msg) ? msg : new UnmodifiableMessage(msg); }
@SuppressWarnings("unchecked") private static <T extends MessageVisitor> T unmodifiableVisitor(T visitor) { return isUnmodifiable(visitor) ? visitor : (T) new UnmodifiableMessageVisitor(visitor); }
/** * Returns an unmodifiable wrapper around the message. When accessing structures or types of the * {@link UnmodifiableMessage}, they will be unmodifiable as well. Copying these message parts into a regular * message should therefore be done using {@link ca.uhn.hl7v2.util.DeepCopy}. * * @param msg message to be wrapped * @return unmodifiable message wrapper */ public static Message unmodifiableMessage(Message msg) { return isUnmodifiable(msg) ? msg : new UnmodifiableMessage(msg); }
@SuppressWarnings("unchecked") private static ExtraComponents unmodifiableExtraComponents(ExtraComponents ec) { return isUnmodifiable(ec) ? ec : new UnmodifiableExtraComponents(ec); }
@SuppressWarnings("unchecked") private static <T extends MessageVisitor> T unmodifiableVisitor(T visitor) { return isUnmodifiable(visitor) ? visitor : (T) new UnmodifiableMessageVisitor(visitor); }
@SuppressWarnings("unchecked") private static ExtraComponents unmodifiableExtraComponents(ExtraComponents ec) { return isUnmodifiable(ec) ? ec : new UnmodifiableExtraComponents(ec); }
@SuppressWarnings("unchecked") private static <T extends Structure> T unmodifiableStructure(T structure) { if (isUnmodifiable(structure)) return structure; if (structure instanceof Message) return (T) new UnmodifiableMessage((Message) structure); if (structure instanceof Group) return (T) new UnmodifiableGroup((Group) structure); return (T) new UnmodifiableSegment((Segment) structure); }
@SuppressWarnings("unchecked") private static <T extends Type> T unmodifiableType(T type) { if (isUnmodifiable(type)) return type; if (type instanceof Primitive) return (T) new UnmodifiablePrimitive((Primitive) type); if (type instanceof Composite) return (T) new UnmodifiableComposite((Composite) type); return (T) new UnmodifiableVaries((Variable) type); }
@SuppressWarnings("unchecked") private static <T extends Type> T unmodifiableType(T type) { if (isUnmodifiable(type)) return type; if (type instanceof Primitive) return (T) new UnmodifiablePrimitive((Primitive) type); if (type instanceof Composite) return (T) new UnmodifiableComposite((Composite) type); return (T) new UnmodifiableVaries((Variable) type); }
@SuppressWarnings("unchecked") private static <T extends Structure> T unmodifiableStructure(T structure) { if (isUnmodifiable(structure)) return structure; if (structure instanceof Message) return (T) new UnmodifiableMessage((Message) structure); if (structure instanceof Group) return (T) new UnmodifiableGroup((Group) structure); return (T) new UnmodifiableSegment((Segment) structure); }