cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

Java SDK warning regarding deprecated data type

manasvi
12-Amethyst

Java SDK warning regarding deprecated data type

It may be silly but I couldnt find the latest contructor for primitive data types .I get the warning while setting property

 

"The constructor NumberPrimitive(Double) is deprecated"

 

What is the new constructor format? Or if somebody can point to the correct documentation.

ACCEPTED SOLUTION

Accepted Solutions
pgrodowski
13-Aquamarine
(To:manasvi)

Hello,

 

The correct documentation can be found here:

http://support.ptc.com/help/thingworx_hc/javadoc/com/thingworx/types/primitives/NumberPrimitive.html

 

The constructors you mentioned are indeed marked as deprecated.

 

The recommended way to create a number primitive from other types seems to be the use of the static function creating a NumberPrimitive from a Object.

 

public static NumberPrimitive convertFromObject(java.lang.Object data)

See also:

http://support.ptc.com/help/thingworx_hc/javadoc/com/thingworx/types/primitives/NumberPrimitive.html#convertFromObject-java.lang.Object-

 

Another option is to use the common superclass Number of most numerical Java types in the constructor:

public NumberPrimitive(java.lang.Number value)

See:

http://support.ptc.com/help/thingworx_hc/javadoc/com/thingworx/types/primitives/NumberPrimitive.html#NumberPrimitive-java.lang.Number-

 

Let me know if you're still encountering problems or questions.

 

Regards,

Pascal

View solution in original post

1 REPLY 1
pgrodowski
13-Aquamarine
(To:manasvi)

Hello,

 

The correct documentation can be found here:

http://support.ptc.com/help/thingworx_hc/javadoc/com/thingworx/types/primitives/NumberPrimitive.html

 

The constructors you mentioned are indeed marked as deprecated.

 

The recommended way to create a number primitive from other types seems to be the use of the static function creating a NumberPrimitive from a Object.

 

public static NumberPrimitive convertFromObject(java.lang.Object data)

See also:

http://support.ptc.com/help/thingworx_hc/javadoc/com/thingworx/types/primitives/NumberPrimitive.html#convertFromObject-java.lang.Object-

 

Another option is to use the common superclass Number of most numerical Java types in the constructor:

public NumberPrimitive(java.lang.Number value)

See:

http://support.ptc.com/help/thingworx_hc/javadoc/com/thingworx/types/primitives/NumberPrimitive.html#NumberPrimitive-java.lang.Number-

 

Let me know if you're still encountering problems or questions.

 

Regards,

Pascal

Announcements

Top Tags