List of usage examples for org.apache.commons.lang3 Validate isTrue
public static void isTrue(final boolean expression)
Validate that the argument condition is true ; otherwise throwing an exception.
From source file:co.runrightfast.commons.utils.ValidationUtils.java
static void greaterThanOrEqualZero(final int n) { Validate.isTrue(n >= 0); }
From source file:co.runrightfast.commons.utils.ValidationUtils.java
static void greaterThanZero(final int n) { Validate.isTrue(n > 0); }
From source file:com.offbynull.coroutines.instrumenter.InternalUtils.java
@SuppressWarnings("unchecked") static <T extends ContinuationPoint> T validateAndGetContinuationPoint(MethodAttributes attrs, int idx, Class<T> expectedType) { Validate.notNull(attrs);//from w ww .ja va 2 s . c om Validate.notNull(expectedType); Validate.isTrue(idx >= 0); List<ContinuationPoint> continuationPoints = attrs.getContinuationPoints(); Validate.isTrue(idx < continuationPoints.size()); ContinuationPoint continuationPoint = continuationPoints.get(idx); Validate.isTrue(expectedType.isAssignableFrom(continuationPoint.getClass())); return (T) continuationPoint; }
From source file:de.pixida.logtest.engine.Event.java
private Event(final boolean aEof) { Validate.isTrue(aEof); this.logEntry = null; this.eof = aEof; }
From source file:com.offbynull.coroutines.instrumenter.ContinuationPointInstructionUtils.java
static InsnList castToObjectAndSave(Type originalType, Variable variable) { Validate.notNull(originalType);//ww w . ja v a 2 s .c om Validate.notNull(variable); Validate.isTrue(variable.getType().equals(Type.getType(Object.class))); InsnList ret = new InsnList(); switch (originalType.getSort()) { case Type.BOOLEAN: ret.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "java/lang/Boolean", "valueOf", "(Z)Ljava/lang/Boolean;", false)); ret.add(saveVar(variable)); // save it in to the returnValObj break; case Type.BYTE: ret.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "java/lang/Byte", "valueOf", "(B)Ljava/lang/Byte;", false)); ret.add(saveVar(variable)); // save it in to the returnValObj break; case Type.SHORT: ret.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "java/lang/Short", "valueOf", "(S)Ljava/lang/Short;", false)); ret.add(saveVar(variable)); // save it in to the returnValObj break; case Type.CHAR: ret.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "java/lang/Character", "valueOf", "(C)Ljava/lang/Character;", false)); ret.add(saveVar(variable)); // save it in to the returnValObj break; case Type.INT: ret.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "java/lang/Integer", "valueOf", "(I)Ljava/lang/Integer;", false)); ret.add(saveVar(variable)); // save it in to the returnValObj break; case Type.FLOAT: ret.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "java/lang/Float", "valueOf", "(F)Ljava/lang/Float;", false)); ret.add(saveVar(variable)); // save it in to the returnValObj break; case Type.LONG: ret.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "java/lang/Long", "valueOf", "(J)Ljava/lang/Long;", false)); ret.add(saveVar(variable)); // save it in to the returnValObj break; case Type.DOUBLE: ret.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "java/lang/Double", "valueOf", "(D)Ljava/lang/Double;", false)); ret.add(saveVar(variable)); // save it in to the returnValObj break; case Type.ARRAY: case Type.OBJECT: ret.add(saveVar(variable)); // save it in to the returnValObj break; case Type.VOID: break; case Type.METHOD: default: throw new IllegalArgumentException(); } return ret; }
From source file:com.offbynull.voip.audio.gateways.io.InputData.java
public InputData(byte[] data, int len) { Validate.notNull(data);/*from ww w . j av a2s .c om*/ Validate.isTrue(len >= 0); Validate.isTrue(len <= data.length); this.data = Arrays.copyOf(data, len); }
From source file:com.skelril.nitro.droptable.DropTableImpl.java
public DropTableImpl(DiceRoller roller, List<DropTableEntry> possible) { this.roller = roller; // First sort possible, then apply possible.sort((a, b) -> a.getChance() - b.getChance()); Validate.isTrue(!possible.isEmpty() && possible.get(0).getChance() > 0); this.possible = ImmutableList.copyOf(possible); }
From source file:com.offbynull.voip.kademlia.model.Id.java
/** * Constructs an {@link Id} from a bit string. * @param data id value// w w w . j ava 2 s . c o m * @return created id * @throws NullPointerException if any argument is {@code null} */ public static Id create(BitString data) { Validate.notNull(data); Validate.isTrue(data.getBitLength() > 0); return new Id(data); }
From source file:com.offbynull.coroutines.instrumenter.StorageContainerVariables.java
StorageContainerVariables(Variable containerVar) {
Validate.notNull(containerVar);//w w w . j a v a2 s. c om
Validate.isTrue(containerVar.getType().equals(Type.getType(Object[].class)));
this.containerVar = containerVar;
}
From source file:chat.viska.xmpp.Version.java
/** * Constructs with parts specified.//from w w w. jav a 2s . com */ public Version(int major, int minor) { Validate.isTrue(major >= 0); Validate.isTrue(minor >= 0); this.major = major; this.minor = minor; }