/** * Copy the current immutable object by setting a value for the {@link SMFFormatVersionType#minor() minor} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for minor * @return A modified copy of the {@code this} object */ public final SMFFormatVersion withMinor(int value) { if (this.minor == value) return this; return new SMFFormatVersion(this.major, value); }
/** * This instance is equal to all instances of {@code SMFFormatVersion} that have equal attribute values. * @return {@code true} if {@code this} is equal to {@code another} instance */ @Override public boolean equals(Object another) { if (this == another) return true; return another instanceof SMFFormatVersion && equalTo((SMFFormatVersion) another); }
private boolean equalTo(SMFVersionProbed another) { return provider.equals(another.provider) && version.equals(another.version); }
/** * Converts to {@link SMFFormatVersion SMFFormatVersion}. * @return An immutable instance of SMFFormatVersion */ public final SMFFormatVersion toImmutable() { checkRequiredAttributes(); return SMFFormatVersion.copyOf(this); }
/** * Creates an immutable copy of a {@link SMFFormatVersionType} value. * Uses accessors to get values to initialize the new immutable instance. * If an instance is already immutable, it is returned as is. * @param instance The instance to copy * @return A copied immutable SMFFormatVersion instance */ public static SMFFormatVersion copyOf(SMFFormatVersionType instance) { if (instance instanceof SMFFormatVersion) { return (SMFFormatVersion) instance; } return SMFFormatVersion.builder() .from(instance) .build(); }
@Override public void parse() { this.events.onStart(); try { final Optional<SMFParserEventsHeaderType> r_opt = this.events.onVersionReceived(SMFFormatVersion.of(1, 0)); if (r_opt.isPresent()) { final SMFParserEventsHeaderType r = r_opt.get(); this.parseBody(r.onHeaderParsed(this.mesh.header())); } } finally { this.events.onFinish(); } }
@Override public SMFSerializerType serializerCreate( final SMFFormatVersion version, final Path path, final OutputStream stream) throws UnsupportedOperationException { if (SUPPORTED.contains(version)) { return new SMFTV1Serializer(version, path, stream); } throw new UnsupportedOperationException( String.format( "Version %d.%d is not supported", Integer.valueOf(version.major()), Integer.valueOf(version.minor()))); }
final SMFFormatVersion version = v_version.get(); super.events.onVersionReceived(version); switch (version.major()) { case 1: { LOG.debug("instantiating 1.* parser");
/** * Computes a hash code from attributes: {@code provider}, {@code version}. * @return hashCode value */ @Override public int hashCode() { int h = 5381; h += (h << 5) + provider.hashCode(); h += (h << 5) + version.hashCode(); return h; }
/** * Converts to {@link SMFFormatVersion SMFFormatVersion}. * @return An immutable instance of SMFFormatVersion */ public final SMFFormatVersion toImmutable() { checkRequiredAttributes(); return SMFFormatVersion.copyOf(this); }
/** * Creates an immutable copy of a {@link SMFFormatVersionType} value. * Uses accessors to get values to initialize the new immutable instance. * If an instance is already immutable, it is returned as is. * @param instance The instance to copy * @return A copied immutable SMFFormatVersion instance */ public static SMFFormatVersion copyOf(SMFFormatVersionType instance) { if (instance instanceof SMFFormatVersion) { return (SMFFormatVersion) instance; } return SMFFormatVersion.builder() .from(instance) .build(); }
final int major = Integer.parseUnsignedInt(line.get(1)); final int minor = Integer.parseUnsignedInt(line.get(2)); return valid(SMFFormatVersion.of(major, minor)); } catch (final NumberFormatException e) { return invalid(List.of(this.makeErrorExpectedGot(
/** * Copy the current immutable object by setting a value for the {@link SMFFormatVersionType#major() major} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for major * @return A modified copy of the {@code this} object */ public final SMFFormatVersion withMajor(int value) { if (this.major == value) return this; return new SMFFormatVersion(value, this.minor); }
/** * This instance is equal to all instances of {@code SMFFormatVersion} that have equal attribute values. * @return {@code true} if {@code this} is equal to {@code another} instance */ @Override public boolean equals(Object another) { if (this == another) return true; return another instanceof SMFFormatVersion && equalTo((SMFFormatVersion) another); }
/** * Construct a new immutable {@code SMFFormatVersion} instance. * @param major The value for the {@code major} attribute * @param minor The value for the {@code minor} attribute * @return An immutable SMFFormatVersion instance */ public static SMFFormatVersion of(int major, int minor) { return new SMFFormatVersion(major, minor); }
/** * Copy the current immutable object by setting a value for the {@link SMFFormatVersionType#major() major} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for major * @return A modified copy of the {@code this} object */ public final SMFFormatVersion withMajor(int value) { if (this.major == value) return this; return new SMFFormatVersion(value, this.minor); }
/** * Copy the current immutable object by setting a value for the {@link SMFFormatVersionType#minor() minor} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for minor * @return A modified copy of the {@code this} object */ public final SMFFormatVersion withMinor(int value) { if (this.minor == value) return this; return new SMFFormatVersion(this.major, value); }
/** * Construct a new immutable {@code SMFFormatVersion} instance. * @param major The value for the {@code major} attribute * @param minor The value for the {@code minor} attribute * @return An immutable SMFFormatVersion instance */ public static SMFFormatVersion of(int major, int minor) { return new SMFFormatVersion(major, minor); }