Class Property
- java.lang.Object
-
- com.deviceatlas.cloud.deviceidentification.client.Property
-
public class Property extends java.lang.Object
Contains a property value. The value can be fetched as a generic Object or one of the convenience asXXXX methods can be used to get the value in a specific type. Copyright (c) DeviceAtlas Limited 2023. All Rights Reserved.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
asBoolean()
Get the value of the property as a boolean.int
asInteger()
Get the value of the property as an int.java.util.Set
asSet()
Gets a set of possible values for this property.java.lang.String
asString()
Get the value of the property as a String.boolean
equals(java.lang.Object obj)
Check if another object is equal to this object.java.lang.String
getDataType()
Get the data type name for values associated with this Propertybyte
getDataTypeId()
Get the data type ID for values associated with this Propertyint
hashCode()
java.lang.String
toString()
Get the value of the property as a String.java.lang.Object
value()
Get the value Object.
-
-
-
Constructor Detail
-
Property
public Property(java.lang.Object value, byte dataTypeId)
Create a new Property with a value and data type.- Parameters:
value
- The value to storedataTypeId
- The type of the value to store. Data typess are defined in class DataType.
-
Property
public Property(java.lang.Object value, byte dataTypeId, boolean isCollectionOfValues)
Create a new Property with a value and data type.- Parameters:
value
- The value to storedataTypeId
- The type of the value to store. Data typess are defined in class DataType.isCollectionOfValues
- Indicates if the Property will contain a single value or multiple values
-
-
Method Detail
-
getDataTypeId
public byte getDataTypeId()
Get the data type ID for values associated with this Property- Returns:
- The ID of the data type
-
getDataType
public java.lang.String getDataType()
Get the data type name for values associated with this Property- Returns:
- The name of the data type
-
value
public java.lang.Object value()
Get the value Object. This needs to be cast to the appropriate type such as Integer to be used. E.g. Integer value = (Integer)property.value();- Returns:
- The raw Object value.
-
toString
public java.lang.String toString()
Get the value of the property as a String. Alias for asString() . If a property has multiple possible values then the values are concatenated with a comma.- Overrides:
toString
in classjava.lang.Object
- Returns:
- The String value of the property
-
asString
public java.lang.String asString()
Get the value of the property as a String. Alias for toString() .- Returns:
- The String value of the property
-
asBoolean
public boolean asBoolean() throws IncorrectPropertyTypeException
Get the value of the property as a boolean.- Returns:
- The boolean value of the property
- Throws:
IncorrectPropertyTypeException
- Thrown if the type of the value is not a DataType.BOOLEAN
-
asInteger
public int asInteger() throws IncorrectPropertyTypeException
Get the value of the property as an int.- Returns:
- The integer value of the property.
- Throws:
IncorrectPropertyTypeException
- Thrown if the type of the value is not compatible with a DataType.INTEGER
-
asSet
public java.util.Set asSet()
Gets a set of possible values for this property. This is typically only used when it is known that a given property name can have multiple possible values. All items in the set will have the same data tyoe.- Returns:
- A set of values.
-
equals
public boolean equals(java.lang.Object obj)
Check if another object is equal to this object. It must have the same interface, data type and value.- Overrides:
equals
in classjava.lang.Object
- Parameters:
obj
- object to be compared against
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-