All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ai.vespa.validation.StringWrapper Maven / Gradle / Ivy

Go to download

Library for use in Java components of Vespa. Shared code which do not fit anywhere else.

There is a newer version: 8.409.18
Show newest version
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package ai.vespa.validation;

import static java.util.Objects.requireNonNull;

/**
 * Abstract wrapper for glorified strings, to ease adding new such wrappers.
 * 

*
* What's in a name?
* That which we call a String
* by any other name would smell as foul.
* No? 'Tis not sooth?
* No ... I see it now!
* Baptiz'd a-new, the String—
* no more a String,
* no less a {@link #value}—
* it bringeth counsel
* and is proof against their enmity.
*

* @param child type * * @author jonmv */ public abstract class StringWrapper> implements Comparable { private final String value; protected StringWrapper(String value) { this.value = requireNonNull(value); } public final String value() { return value; } @Override public int compareTo(T other) { return value().compareTo(other.value()); } @Override public final boolean equals(Object o) { return this == ( o) || (o ) instanceof StringWrapper < ?> w && ( value.equals(w.value)); } @Override public final int hashCode() { return value.hashCode(); } @Override public String toString() { return value; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy