X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fcds-access-api%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Faccess%2Fconcepts%2FFrontendType.java;h=95857e8393a1fd85e0146ab98b55f13650c99bbf;hb=refs%2Fchanges%2F73%2F47473%2F4;hp=471b489046fb20fab5b0789275dcb67391bcf7a2;hpb=93fd13870364f77c234d6bd981906d7ef3bd3b46;p=controller.git diff --git a/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/FrontendType.java b/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/FrontendType.java index 471b489046..95857e8393 100644 --- a/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/FrontendType.java +++ b/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/FrontendType.java @@ -12,6 +12,7 @@ import com.google.common.base.MoreObjects; import com.google.common.base.Preconditions; import com.google.common.base.Strings; import com.google.common.base.Verify; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.io.DataInput; import java.io.DataOutput; import java.io.Externalizable; @@ -22,6 +23,7 @@ import java.nio.charset.StandardCharsets; import java.util.regex.Pattern; import javax.annotation.RegEx; import org.opendaylight.yangtools.concepts.Identifier; +import org.opendaylight.yangtools.concepts.WritableIdentifier; /** * An {@link Identifier} identifying a data store frontend type, which is able to access the data store backend. @@ -31,11 +33,14 @@ import org.opendaylight.yangtools.concepts.Identifier; * @author Robert Varga */ @Beta -public final class FrontendType implements Comparable, Identifier, WritableObject { +public final class FrontendType implements Comparable, WritableIdentifier { private static final class Proxy implements Externalizable { private static final long serialVersionUID = 1L; private byte[] serialized; + // checkstyle flags the public modifier as redundant however it is explicitly needed for Java serialization to + // be able to create instances via reflection. + @SuppressWarnings("checkstyle:RedundantModifier") public Proxy() { // For Externalizable } @@ -67,6 +72,9 @@ public final class FrontendType implements Comparable, Identifier, private static final Pattern SIMPLE_STRING_PATTERN = Pattern.compile(SIMPLE_STRING_REGEX); private static final long serialVersionUID = 1L; private final String name; + + @SuppressFBWarnings(value = "VO_VOLATILE_REFERENCE_TO_ARRAY", + justification = "The array elements are non-volatile but we don't access them.") private volatile byte[] serialized; private FrontendType(final String name) { @@ -84,6 +92,7 @@ public final class FrontendType implements Comparable, Identifier, * - US-ASCII letters and numbers * - special characters: -_.*+:=,!~'; * + * @param name the input name * @return A {@link FrontendType} instance * @throws IllegalArgumentException if the string is null, empty or contains invalid characters */ @@ -102,9 +111,9 @@ public final class FrontendType implements Comparable, Identifier, @Override public void writeTo(final DataOutput out) throws IOException { - final byte[] serialized = getSerialized(); - out.writeInt(serialized.length); - out.write(serialized); + final byte[] local = getSerialized(); + out.writeInt(local.length); + out.write(local); } public String getName() { @@ -117,13 +126,13 @@ public final class FrontendType implements Comparable, Identifier, } @Override - public boolean equals(final Object o) { - return this == o || (o instanceof FrontendType && name.equals(((FrontendType)o).name)); + public boolean equals(final Object obj) { + return this == obj || obj instanceof FrontendType && name.equals(((FrontendType)obj).name); } @Override - public int compareTo(final FrontendType o) { - return this == o ? 0 : name.compareTo(o.name); + public int compareTo(final FrontendType obj) { + return this == obj ? 0 : name.compareTo(obj.name); } @Override