/** * A {@code long} specialized version of {@link #checkPrecondition(Object, * ContractConditionType)}. * * @param value The value * @param condition The predicate * * @return value * * @throws PreconditionViolationException If the predicate is false */ public static long checkPreconditionL( final long value, final ContractLongConditionType condition) throws PreconditionViolationException { return checkPreconditionL( value, condition.predicate(), condition.describer()); }
/** * A {@code long} specialized version of {@link #checkPrecondition(Object, * ContractConditionType)}. * * @param value The value * @param condition The predicate * * @return value * * @throws PreconditionViolationException If the predicate is false */ public static long checkPreconditionL( final long value, final ContractLongConditionType condition) throws PreconditionViolationException { return checkPreconditionL( value, condition.predicate(), condition.describer()); }
private void evict( final C context, final TimedEntry<K, T> e) { Preconditions.checkPrecondition( e.key, this.entries_free.containsKey(e.key), k -> "Key " + k + " must be free"); Preconditions.checkPreconditionL( this.size_now, Long.compareUnsigned(this.size_now, 0L) > 0, x -> "Size " + x + " must be > 0"); final SortedSet<TimedEntry<K, T>> free = this.entries_free.get(e.key); free.remove(e); this.entries_free_timed.remove(e); this.size_now = BigUnsigned.checkedSubtractLong(this.size_now, e.size); Postconditions.checkPostconditionL( this.size_now, Long.compareUnsigned(this.size_now, 0L) >= 0, x -> "Size " + x + " must be >= 0"); this.listener.onDelete(context, e.key, e.value); }
/** * Check preconditions for the type. */ @Value.Check default void checkPreconditions() { { final long tri_lsize = (long) this.triangles().size(); final long tri_hcount = this.header().triangles().triangleCount(); Preconditions.checkPreconditionL( tri_lsize, tri_lsize == tri_hcount, x -> "Triangle list size must match header count"); } { this.arrays().forEach(p -> { final long array_lsize = (long) p._2.size(); final long array_hcount = this.header().vertexCount(); Preconditions.checkPreconditionL( array_lsize, array_lsize == array_hcount, x -> "Attribute array size must match header count"); }); } } }
/** * @return A cursor that can access individual triangles */ @Value.Lazy default JPRACursor1DType<SMFByteBufferIntegerUnsigned3Type> cursor() { Preconditions.checkPreconditionL( this.triangleCount(), Long.compareUnsigned(this.triangleCount(), 0L) > 0, x -> "Triangle count must be non-zero"); return SMFByteBufferCursors.createUnsigned3Raw( this.byteBuffer(), this.triangleIndexSizeBits(), 0, this.triangleSizeOctets()); }