You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2016/12/17 07:08:29 UTC
svn commit: r1774711 - in
/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry:
AbstractValue.java BinaryValue.java DefaultAttribute.java
Author: elecharny
Date: Sat Dec 17 07:08:29 2016
New Revision: 1774711
URL: http://svn.apache.org/viewvc?rev=1774711&view=rev
Log:
Fixed sonarlint warnings
Modified:
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/AbstractValue.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/BinaryValue.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/DefaultAttribute.java
Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/AbstractValue.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/AbstractValue.java?rev=1774711&r1=1774710&r2=1774711&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/AbstractValue.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/AbstractValue.java Sat Dec 17 07:08:29 2016
@@ -63,6 +63,7 @@ public abstract class AbstractValue<T> i
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
+ @Override
public Value<T> clone()
{
try
@@ -80,6 +81,7 @@ public abstract class AbstractValue<T> i
/**
* {@inheritDoc}
*/
+ @Override
public T getReference()
{
return upValue;
@@ -91,6 +93,7 @@ public abstract class AbstractValue<T> i
*
* @return the wrapped value as a String
*/
+ @Override
public String getString()
{
throw new UnsupportedOperationException( "Cannot call this method on a binary value" );
@@ -102,6 +105,7 @@ public abstract class AbstractValue<T> i
*
* @return the wrapped value as a byte[]
*/
+ @Override
public byte[] getBytes()
{
throw new UnsupportedOperationException( "Cannot call this method on a String value" );
@@ -111,6 +115,7 @@ public abstract class AbstractValue<T> i
/**
* {@inheritDoc}
*/
+ @Override
public AttributeType getAttributeType()
{
return attributeType;
@@ -125,6 +130,7 @@ public abstract class AbstractValue<T> i
* to the schema
*/
@SuppressWarnings("unchecked")
+ @Override
public void apply( AttributeType attributeType ) throws LdapInvalidAttributeValueException
{
if ( this.attributeType != null )
@@ -264,6 +270,7 @@ public abstract class AbstractValue<T> i
/**
* {@inheritDoc}
*/
+ @Override
public boolean isInstanceOf( AttributeType attributeType )
{
return ( attributeType != null )
@@ -274,6 +281,7 @@ public abstract class AbstractValue<T> i
/**
* {@inheritDoc}
*/
+ @Override
public T getNormReference()
{
if ( isNull() )
@@ -293,6 +301,7 @@ public abstract class AbstractValue<T> i
/**
* {@inheritDoc}
*/
+ @Override
public final boolean isNull()
{
return upValue == null;
@@ -302,6 +311,7 @@ public abstract class AbstractValue<T> i
/**
* {@inheritDoc}
*/
+ @Override
public final boolean isValid( SyntaxChecker syntaxChecker ) throws LdapInvalidAttributeValueException
{
if ( syntaxChecker == null )
@@ -325,6 +335,7 @@ public abstract class AbstractValue<T> i
/**
* {@inheritDoc}
*/
+ @Override
public final boolean isSchemaAware()
{
return attributeType != null;
Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/BinaryValue.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/BinaryValue.java?rev=1774711&r1=1774710&r2=1774711&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/BinaryValue.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/BinaryValue.java Sat Dec 17 07:08:29 2016
@@ -120,6 +120,7 @@ public class BinaryValue extends Abstrac
*
* @return the normalized version of the user provided value
*/
+ @Override
public byte[] getNormValue()
{
if ( isNull() )
@@ -139,6 +140,7 @@ public class BinaryValue extends Abstrac
* @param value The value we want to compare to
* @return -1 if the current is below the provided one, 1 if it's above, 0 if they are equal
*/
+ @Override
public int compareTo( Value<byte[]> value )
{
if ( isNull() )
@@ -200,6 +202,7 @@ public class BinaryValue extends Abstrac
* @see Object#hashCode()
* @return the instance's hashcode
*/
+ @Override
public int hashCode()
{
if ( h == 0 )
@@ -225,6 +228,7 @@ public class BinaryValue extends Abstrac
* This equals implementation overrides the BinaryValue implementation which
* is not schema aware.
*/
+ @Override
public boolean equals( Object obj )
{
if ( this == obj )
@@ -399,6 +403,7 @@ public class BinaryValue extends Abstrac
/**
* {@inheritDoc}
*/
+ @Override
public BinaryValue clone()
{
BinaryValue clone = ( BinaryValue ) super.clone();
@@ -423,6 +428,7 @@ public class BinaryValue extends Abstrac
/**
* {@inheritDoc}
*/
+ @Override
public byte[] getValue()
{
if ( upValue == null )
@@ -442,6 +448,7 @@ public class BinaryValue extends Abstrac
*
* @return <code>true</code> if the value is HR, <code>false</code> otherwise
*/
+ @Override
public boolean isHumanReadable()
{
return false;
@@ -451,6 +458,7 @@ public class BinaryValue extends Abstrac
/**
* @return The length of the interned value
*/
+ @Override
public int length()
{
return upValue != null ? upValue.length : 0;
@@ -463,6 +471,7 @@ public class BinaryValue extends Abstrac
*
* @return the user provided value as a byte[]
*/
+ @Override
public byte[] getBytes()
{
return getValue();
@@ -474,6 +483,7 @@ public class BinaryValue extends Abstrac
*
* @return the user provided value as a String
*/
+ @Override
public String getString()
{
return Strings.utf8ToString( upValue );
@@ -519,6 +529,7 @@ public class BinaryValue extends Abstrac
/**
* {@inheritDoc}
*/
+ @Override
public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException
{
// Read the BINARY flag
@@ -620,6 +631,7 @@ public class BinaryValue extends Abstrac
/**
* {@inheritDoc}
*/
+ @Override
public void writeExternal( ObjectOutput out ) throws IOException
{
// Write the BINARY flag
@@ -677,6 +689,7 @@ public class BinaryValue extends Abstrac
*
* @see Object#toString()
*/
+ @Override
public String toString()
{
if ( upValue == null )
Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/DefaultAttribute.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/DefaultAttribute.java?rev=1774711&r1=1774710&r2=1774711&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/DefaultAttribute.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/DefaultAttribute.java Sat Dec 17 07:08:29 2016
@@ -54,7 +54,7 @@ public class DefaultAttribute implements
private AttributeType attributeType;
/** The set of contained values */
- private Set<Value<?>> values = new LinkedHashSet<Value<?>>();
+ private Set<Value<?>> values = new LinkedHashSet<>();
/** The User provided ID */
private String upId;
@@ -71,51 +71,6 @@ public class DefaultAttribute implements
//-------------------------------------------------------------------------
- // Helper methods
- //-------------------------------------------------------------------------
- private Value<String> createStringValue( AttributeType attributeType, String value )
- {
- Value<String> stringValue = null;
-
- if ( attributeType != null )
- {
- try
- {
- stringValue = new StringValue( attributeType, value );
- }
- catch ( LdapInvalidAttributeValueException iae )
- {
- return null;
- }
- }
- else
- {
- stringValue = new StringValue( value );
- }
-
- return stringValue;
- }
-
-
- private Value<byte[]> createBinaryValue( AttributeType attributeType, byte[] value )
- throws LdapInvalidAttributeValueException
- {
- Value<byte[]> binaryValue = null;
-
- if ( attributeType != null )
- {
- binaryValue = new BinaryValue( attributeType, value );
- }
- else
- {
- binaryValue = new BinaryValue( value );
- }
-
- return binaryValue;
- }
-
-
- //-------------------------------------------------------------------------
// Constructors
//-------------------------------------------------------------------------
// maybe have some additional convenience constructors which take
@@ -506,9 +461,55 @@ public class DefaultAttribute implements
}
+ //-------------------------------------------------------------------------
+ // Helper methods
+ //-------------------------------------------------------------------------
+ private Value<String> createStringValue( AttributeType attributeType, String value )
+ {
+ Value<String> stringValue;
+
+ if ( attributeType != null )
+ {
+ try
+ {
+ stringValue = new StringValue( attributeType, value );
+ }
+ catch ( LdapInvalidAttributeValueException iae )
+ {
+ return null;
+ }
+ }
+ else
+ {
+ stringValue = new StringValue( value );
+ }
+
+ return stringValue;
+ }
+
+
+ private Value<byte[]> createBinaryValue( AttributeType attributeType, byte[] value )
+ throws LdapInvalidAttributeValueException
+ {
+ Value<byte[]> binaryValue;
+
+ if ( attributeType != null )
+ {
+ binaryValue = new BinaryValue( attributeType, value );
+ }
+ else
+ {
+ binaryValue = new BinaryValue( value );
+ }
+
+ return binaryValue;
+ }
+
+
/**
* {@inheritDoc}
*/
+ @Override
public byte[] getBytes() throws LdapInvalidAttributeValueException
{
Value<?> value = get();
@@ -527,6 +528,7 @@ public class DefaultAttribute implements
/**
* {@inheritDoc}
*/
+ @Override
public String getString() throws LdapInvalidAttributeValueException
{
Value<?> value = get();
@@ -545,6 +547,7 @@ public class DefaultAttribute implements
/**
* {@inheritDoc}
*/
+ @Override
public String getId()
{
return id;
@@ -554,6 +557,7 @@ public class DefaultAttribute implements
/**
* {@inheritDoc}
*/
+ @Override
public String getUpId()
{
return upId;
@@ -563,6 +567,7 @@ public class DefaultAttribute implements
/**
* {@inheritDoc}
*/
+ @Override
public void setUpId( String upId )
{
setUpId( upId, attributeType );
@@ -611,6 +616,7 @@ public class DefaultAttribute implements
/**
* {@inheritDoc}
*/
+ @Override
public void setUpId( String upId, AttributeType attributeType )
{
String trimmed = Strings.trim( upId );
@@ -712,6 +718,7 @@ public class DefaultAttribute implements
/**
* {@inheritDoc}
*/
+ @Override
public boolean isHumanReadable()
{
return isHR != null ? isHR : false;
@@ -721,6 +728,7 @@ public class DefaultAttribute implements
/**
* {@inheritDoc}
*/
+ @Override
public boolean isValid( AttributeType attributeType ) throws LdapInvalidAttributeValueException
{
LdapSyntax syntax = attributeType.getSyntax();
@@ -738,7 +746,7 @@ public class DefaultAttribute implements
}
// Check that we can have no value for this attributeType
- if ( values.size() == 0 )
+ if ( values.isEmpty() )
{
return syntaxChecker.isValidSyntax( null );
}
@@ -772,6 +780,7 @@ public class DefaultAttribute implements
/**
* {@inheritDoc}
*/
+ @Override
public int add( Value<?>... vals )
{
int nbAdded = 0;
@@ -1041,6 +1050,7 @@ public class DefaultAttribute implements
/**
* {@inheritDoc}
*/
+ @Override
public int add( String... vals ) throws LdapInvalidAttributeValueException
{
int nbAdded = 0;
@@ -1190,7 +1200,7 @@ public class DefaultAttribute implements
{
for ( byte[] val : valArray )
{
- Value<byte[]> value = null;
+ Value<byte[]> value;
if ( attributeType == null )
{
@@ -1225,6 +1235,7 @@ public class DefaultAttribute implements
/**
* {@inheritDoc}
*/
+ @Override
public void clear()
{
values.clear();
@@ -1234,6 +1245,7 @@ public class DefaultAttribute implements
/**
* {@inheritDoc}
*/
+ @Override
public boolean contains( Value<?>... vals )
{
if ( isHR == null )
@@ -1361,6 +1373,7 @@ public class DefaultAttribute implements
/**
* {@inheritDoc}
*/
+ @Override
public boolean contains( String... vals )
{
if ( isHR == null )
@@ -1520,6 +1533,7 @@ public class DefaultAttribute implements
/**
* {@inheritDoc}
*/
+ @Override
public Value<?> get()
{
if ( values.isEmpty() )
@@ -1534,6 +1548,7 @@ public class DefaultAttribute implements
/**
* {@inheritDoc}
*/
+ @Override
public int size()
{
return values.size();
@@ -1543,9 +1558,10 @@ public class DefaultAttribute implements
/**
* {@inheritDoc}
*/
+ @Override
public boolean remove( Value<?>... vals )
{
- if ( ( isHR == null ) || ( values.size() == 0 ) )
+ if ( ( isHR == null ) || values.isEmpty() )
{
// Trying to remove a value from an empty list will fail
return false;
@@ -1651,7 +1667,7 @@ public class DefaultAttribute implements
*/
public boolean remove( byte[]... vals )
{
- if ( ( isHR == null ) || ( values.size() == 0 ) )
+ if ( ( isHR == null ) || values.isEmpty() )
{
// Trying to remove a value from an empty list will fail
return false;
@@ -1711,9 +1727,10 @@ public class DefaultAttribute implements
/**
* {@inheritDoc}
*/
+ @Override
public boolean remove( String... vals )
{
- if ( ( isHR == null ) || ( values.size() == 0 ) )
+ if ( ( isHR == null ) || values.isEmpty() )
{
// Trying to remove a value from an empty list will fail
return false;
@@ -1775,6 +1792,7 @@ public class DefaultAttribute implements
*
* @return an iterator over the stored values.
*/
+ @Override
public Iterator<Value<?>> iterator()
{
return values.iterator();
@@ -1784,6 +1802,7 @@ public class DefaultAttribute implements
/**
* {@inheritDoc}
*/
+ @Override
public AttributeType getAttributeType()
{
return attributeType;
@@ -1793,6 +1812,7 @@ public class DefaultAttribute implements
/**
* {@inheritDoc}
*/
+ @Override
public void apply( AttributeType attributeType ) throws LdapInvalidAttributeValueException
{
if ( attributeType == null )
@@ -1817,7 +1837,7 @@ public class DefaultAttribute implements
if ( values != null )
{
- Set<Value<?>> newValues = new LinkedHashSet<Value<?>>( values.size() );
+ Set<Value<?>> newValues = new LinkedHashSet<>( values.size() );
for ( Value<?> value : values )
{
@@ -1844,6 +1864,7 @@ public class DefaultAttribute implements
/**
* {@inheritDoc}
*/
+ @Override
public boolean isInstanceOf( AttributeType attributeType ) throws LdapInvalidAttributeValueException
{
return ( attributeType != null )
@@ -1885,6 +1906,7 @@ public class DefaultAttribute implements
* @see Object#hashCode()
* @return the instance's hashcode
*/
+ @Override
public int hashCode()
{
if ( h == 0 )
@@ -1899,6 +1921,7 @@ public class DefaultAttribute implements
/**
* @see Object#equals(Object)
*/
+ @Override
public boolean equals( Object obj )
{
if ( obj == this )
@@ -1972,6 +1995,7 @@ public class DefaultAttribute implements
/**
* {@inheritDoc}
*/
+ @Override
public Attribute clone()
{
try
@@ -1984,7 +2008,7 @@ public class DefaultAttribute implements
attribute.attributeType = attributeType;
}
- attribute.values = new LinkedHashSet<Value<?>>( values.size() );
+ attribute.values = new LinkedHashSet<>( values.size() );
for ( Value<?> value : values )
{
@@ -2007,6 +2031,7 @@ public class DefaultAttribute implements
*
* {@inheritDoc}
*/
+ @Override
public void writeExternal( ObjectOutput out ) throws IOException
{
// Write the UPId (the id will be deduced from the upID)
@@ -2043,6 +2068,7 @@ public class DefaultAttribute implements
/**
* {@inheritDoc}
*/
+ @Override
public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException
{
// Read the ID and the UPId
@@ -2064,7 +2090,7 @@ public class DefaultAttribute implements
{
for ( int i = 0; i < nbValues; i++ )
{
- Value<?> value = null;
+ Value<?> value;
if ( isHR )
{
@@ -2086,7 +2112,8 @@ public class DefaultAttribute implements
/**
* @see Object#toString()
*/
- public String toString()
+ @Override
+public String toString()
{
return toString( "" );
}
@@ -2095,11 +2122,12 @@ public class DefaultAttribute implements
/**
* {@inheritDoc}
*/
+ @Override
public String toString( String tabs )
{
StringBuilder sb = new StringBuilder();
- if ( ( values != null ) && ( values.size() != 0 ) )
+ if ( ( values != null ) && !values.isEmpty() )
{
boolean isFirst = true;