Skip to content

Commit

Permalink
Made internal methods not public
Browse files Browse the repository at this point in the history
  • Loading branch information
jdereg committed Jan 14, 2024
1 parent 6c21323 commit f4880fe
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,57 +7,57 @@

public class AtomicBooleanConversion {

public static Byte toByte(Object from, Converter converter, ConverterOptions options) {
static Byte toByte(Object from, Converter converter, ConverterOptions options) {
AtomicBoolean b = (AtomicBoolean) from;
return b.get() ? CommonValues.BYTE_ONE : CommonValues.BYTE_ZERO;
}

public static Short toShort(Object from, Converter converter, ConverterOptions options) {
static Short toShort(Object from, Converter converter, ConverterOptions options) {
AtomicBoolean b = (AtomicBoolean) from;
return b.get() ? CommonValues.SHORT_ONE : CommonValues.SHORT_ZERO;
}

public static Integer toInteger(Object from, Converter converter, ConverterOptions options) {
static Integer toInteger(Object from, Converter converter, ConverterOptions options) {
AtomicBoolean b = (AtomicBoolean) from;
return b.get() ? CommonValues.INTEGER_ONE : CommonValues.INTEGER_ZERO;
}

public static Long toLong(Object from, Converter converter, ConverterOptions options) {
static Long toLong(Object from, Converter converter, ConverterOptions options) {
AtomicBoolean b = (AtomicBoolean) from;
return b.get() ? CommonValues.LONG_ONE : CommonValues.LONG_ZERO;
}

public static Float toFloat(Object from, Converter converter, ConverterOptions options) {
static Float toFloat(Object from, Converter converter, ConverterOptions options) {
AtomicBoolean b = (AtomicBoolean) from;
return b.get() ? CommonValues.FLOAT_ONE : CommonValues.FLOAT_ZERO;
}

public static Double toDouble(Object from, Converter converter, ConverterOptions options) {
static Double toDouble(Object from, Converter converter, ConverterOptions options) {
AtomicBoolean b = (AtomicBoolean) from;
return b.get() ? CommonValues.DOUBLE_ONE : CommonValues.DOUBLE_ZERO;
}

public static boolean toBoolean(Object from, Converter converter, ConverterOptions options) {
static boolean toBoolean(Object from, Converter converter, ConverterOptions options) {
AtomicBoolean b = (AtomicBoolean) from;
return b.get();
}

public static AtomicInteger toAtomicInteger(Object from, Converter converter, ConverterOptions options) {
static AtomicInteger toAtomicInteger(Object from, Converter converter, ConverterOptions options) {
AtomicBoolean b = (AtomicBoolean) from;
return b.get() ? new AtomicInteger(1) : new AtomicInteger (0);
}

public static AtomicLong toAtomicLong(Object from, Converter converter, ConverterOptions options) {
static AtomicLong toAtomicLong(Object from, Converter converter, ConverterOptions options) {
AtomicBoolean b = (AtomicBoolean) from;
return b.get() ? new AtomicLong(1) : new AtomicLong(0);
}

public static Character toCharacter(Object from, Converter converter, ConverterOptions options) {
static Character toCharacter(Object from, Converter converter, ConverterOptions options) {
AtomicBoolean b = (AtomicBoolean) from;
return b.get() ? CommonValues.CHARACTER_ONE : CommonValues.CHARACTER_ZERO;
}

public static BigDecimal toBigDecimal(Object from, Converter converter, ConverterOptions options) {
static BigDecimal toBigDecimal(Object from, Converter converter, ConverterOptions options) {
AtomicBoolean b = (AtomicBoolean) from;
return b.get() ? BigDecimal.ONE : BigDecimal.ZERO;
}
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/com/cedarsoftware/util/convert/BooleanConversion.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,52 +23,52 @@
* limitations under the License.
*/
public class BooleanConversion {
public static Byte toByte(Object from, Converter converter, ConverterOptions options) {
static Byte toByte(Object from, Converter converter, ConverterOptions options) {
Boolean b = (Boolean) from;
return b ? CommonValues.BYTE_ONE : CommonValues.BYTE_ZERO;
}

public static Short toShort(Object from, Converter converter, ConverterOptions options) {
static Short toShort(Object from, Converter converter, ConverterOptions options) {
Boolean b = (Boolean) from;
return b ? CommonValues.SHORT_ONE : CommonValues.SHORT_ZERO;
}

public static Integer toInteger(Object from, Converter converter, ConverterOptions options) {
static Integer toInteger(Object from, Converter converter, ConverterOptions options) {
Boolean b = (Boolean) from;
return b ? CommonValues.INTEGER_ONE : CommonValues.INTEGER_ZERO;
}

public static AtomicLong toAtomicLong(Object from, Converter converter, ConverterOptions options) {
static AtomicLong toAtomicLong(Object from, Converter converter, ConverterOptions options) {
Boolean b = (Boolean) from;
return new AtomicLong(b ? 1 : 0);
}

public static AtomicBoolean toAtomicBoolean(Object from, Converter converter, ConverterOptions options) {
static AtomicBoolean toAtomicBoolean(Object from, Converter converter, ConverterOptions options) {
Boolean b = (Boolean) from;
return new AtomicBoolean(b);
}

public static Long toLong(Object from, Converter converter, ConverterOptions options) {
static Long toLong(Object from, Converter converter, ConverterOptions options) {
Boolean b = (Boolean) from;
return b.booleanValue() ? CommonValues.LONG_ONE : CommonValues.LONG_ZERO;
}

public static BigDecimal toBigDecimal(Object from, Converter converter, ConverterOptions options) {
static BigDecimal toBigDecimal(Object from, Converter converter, ConverterOptions options) {
Boolean b = (Boolean)from;
return b ? BigDecimal.ONE : BigDecimal.ZERO;
}

public static Float toFloat(Object from, Converter converter, ConverterOptions options) {
static Float toFloat(Object from, Converter converter, ConverterOptions options) {
Boolean b = (Boolean) from;
return b ? CommonValues.FLOAT_ONE : CommonValues.FLOAT_ZERO;
}

public static Double toDouble(Object from, Converter converter, ConverterOptions options) {
static Double toDouble(Object from, Converter converter, ConverterOptions options) {
Boolean b = (Boolean) from;
return b ? CommonValues.DOUBLE_ONE : CommonValues.DOUBLE_ZERO;
}

public static char toCharacter(Object from, Converter converter, ConverterOptions options) {
static char toCharacter(Object from, Converter converter, ConverterOptions options) {
Boolean b = (Boolean) from;
return b ? CommonValues.CHARACTER_ONE : CommonValues.CHARACTER_ZERO;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,25 @@
import java.math.BigInteger;
import java.util.Calendar;
import java.util.Date;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;

public class CalendarConversion {
public static Date toDate(Object fromInstance, Converter converter, ConverterOptions options) {
static Date toDate(Object fromInstance, Converter converter, ConverterOptions options) {
Calendar from = (Calendar)fromInstance;
return from.getTime();
}

public static AtomicLong toAtomicLong(Object fromInstance, Converter converter, ConverterOptions options) {
static AtomicLong toAtomicLong(Object fromInstance, Converter converter, ConverterOptions options) {
Calendar from = (Calendar)fromInstance;
return new AtomicLong(from.getTime().getTime());
}

public static BigDecimal toBigDecimal(Object fromInstance, Converter converter, ConverterOptions options) {
static BigDecimal toBigDecimal(Object fromInstance, Converter converter, ConverterOptions options) {
Calendar from = (Calendar)fromInstance;
return BigDecimal.valueOf(from.getTime().getTime());
}

public static BigInteger toBigInteger(Object fromInstance, Converter converter, ConverterOptions options) {
static BigInteger toBigInteger(Object fromInstance, Converter converter, ConverterOptions options) {
Calendar from = (Calendar)fromInstance;
return BigInteger.valueOf(from.getTime().getTime());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
package com.cedarsoftware.util.convert;

import java.util.concurrent.atomic.AtomicBoolean;

public class CharacterConversion {
public static boolean toBoolean(Object from, Converter converter, ConverterOptions options) {
static boolean toBoolean(Object from, Converter converter, ConverterOptions options) {
Character c = (Character) from;
return c != CommonValues.CHARACTER_ZERO;
}

public static double toDouble(Object from, Converter converter, ConverterOptions options) {
static double toDouble(Object from, Converter converter, ConverterOptions options) {
return (char) from;
}

public static float toFloat(Object from, Converter converter, ConverterOptions options) {
static float toFloat(Object from, Converter converter, ConverterOptions options) {
return (char) from;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,20 @@

import java.math.BigDecimal;
import java.util.Date;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;

public class DateConversion {
public static Date toSqlDate(Object fromInstance, Converter converter, ConverterOptions options) {
static Date toSqlDate(Object fromInstance, Converter converter, ConverterOptions options) {
Date from = (Date)fromInstance;
return new java.sql.Date(from.getTime());
}

public static BigDecimal toBigDecimal(Object fromInstance, Converter converter, ConverterOptions options) {
static BigDecimal toBigDecimal(Object fromInstance, Converter converter, ConverterOptions options) {
Date from = (Date)fromInstance;
return BigDecimal.valueOf(from.getTime());
}

public static AtomicLong toAtomicLong(Object fromInstance, Converter converter, ConverterOptions options) {
static AtomicLong toAtomicLong(Object fromInstance, Converter converter, ConverterOptions options) {
Date from = (Date)fromInstance;
return new AtomicLong(from.getTime());
}
Expand Down
33 changes: 15 additions & 18 deletions src/main/java/com/cedarsoftware/util/convert/MapConversion.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package com.cedarsoftware.util.convert;

import com.cedarsoftware.util.CollectionUtilities;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Date;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
Expand All @@ -16,7 +13,7 @@ public class MapConversion {
private static final String V = "_v";
private static final String VALUE = "value";

public static Object toUUID(Object fromInstance, Converter converter, ConverterOptions options) {
static Object toUUID(Object fromInstance, Converter converter, ConverterOptions options) {
Map<?, ?> map = (Map<?, ?>) fromInstance;

if (map.containsKey("mostSigBits") && map.containsKey("leastSigBits")) {
Expand All @@ -29,60 +26,60 @@ public static Object toUUID(Object fromInstance, Converter converter, ConverterO
throw new IllegalArgumentException("To convert Map to UUID, the Map must contain both 'mostSigBits' and 'leastSigBits' keys");
}

public static Byte toByte(Object fromInstance, Converter converter, ConverterOptions options) {
static Byte toByte(Object fromInstance, Converter converter, ConverterOptions options) {
return fromMapValue(fromInstance, converter, options, Byte.class);
}

public static Short toShort(Object fromInstance, Converter converter, ConverterOptions options) {
static Short toShort(Object fromInstance, Converter converter, ConverterOptions options) {
return fromMapValue(fromInstance, converter, options, Short.class);
}

public static Integer toInt(Object fromInstance, Converter converter, ConverterOptions options) {
static Integer toInt(Object fromInstance, Converter converter, ConverterOptions options) {
return fromMapValue(fromInstance, converter, options, Integer.class);
}

public static Long toLong(Object fromInstance, Converter converter, ConverterOptions options) {
static Long toLong(Object fromInstance, Converter converter, ConverterOptions options) {
return fromMapValue(fromInstance, converter, options, Long.class);
}

public static Float toFloat(Object fromInstance, Converter converter, ConverterOptions options) {
static Float toFloat(Object fromInstance, Converter converter, ConverterOptions options) {
return fromMapValue(fromInstance, converter, options, Float.class);
}

public static Double toDouble(Object fromInstance, Converter converter, ConverterOptions options) {
static Double toDouble(Object fromInstance, Converter converter, ConverterOptions options) {
return fromMapValue(fromInstance, converter, options, Double.class);
}

public static Boolean toBoolean(Object fromInstance, Converter converter, ConverterOptions options) {
static Boolean toBoolean(Object fromInstance, Converter converter, ConverterOptions options) {
return fromMapValue(fromInstance, converter, options, Boolean.class);
}

public static BigDecimal toBigDecimal(Object fromInstance, Converter converter, ConverterOptions options) {
static BigDecimal toBigDecimal(Object fromInstance, Converter converter, ConverterOptions options) {
return fromMapValue(fromInstance, converter, options, BigDecimal.class);
}

public static BigInteger toBigInteger(Object fromInstance, Converter converter, ConverterOptions options) {
static BigInteger toBigInteger(Object fromInstance, Converter converter, ConverterOptions options) {
return fromMapValue(fromInstance, converter, options, BigInteger.class);
}

public static String toString(Object fromInstance, Converter converter, ConverterOptions options) {
static String toString(Object fromInstance, Converter converter, ConverterOptions options) {
return fromMapValue(fromInstance, converter, options, String.class);
}


public static AtomicInteger toAtomicInteger(Object fromInstance, Converter converter, ConverterOptions options) {
static AtomicInteger toAtomicInteger(Object fromInstance, Converter converter, ConverterOptions options) {
return fromMapValue(fromInstance, converter, options, AtomicInteger.class);
}

public static AtomicLong toAtomicLong(Object fromInstance, Converter converter, ConverterOptions options) {
static AtomicLong toAtomicLong(Object fromInstance, Converter converter, ConverterOptions options) {
return fromMapValue(fromInstance, converter, options, AtomicLong.class);
}

public static AtomicBoolean toAtomicBoolean(Object fromInstance, Converter converter, ConverterOptions options) {
static AtomicBoolean toAtomicBoolean(Object fromInstance, Converter converter, ConverterOptions options) {
return fromMapValue(fromInstance, converter, options, AtomicBoolean.class);
}

public static <T> T fromMapValue(Object fromInstance, Converter converter, ConverterOptions options, Class<T> type) {
static <T> T fromMapValue(Object fromInstance, Converter converter, ConverterOptions options, Class<T> type) {
Map<?, ?> map = (Map<?, ?>) fromInstance;

if (map.containsKey(V)) {
Expand Down
Loading

0 comments on commit f4880fe

Please sign in to comment.