use of javax.annotation.Nullable in project storm by apache.
the class TestExprSemantic method testJDBCNumericFunctions.
@Test
public void testJDBCNumericFunctions() throws Exception {
Values v = testExpr(Lists.newArrayList("{fn POWER(3, 2)}", "{fn ABS(-10)}", "{fn MOD(10, 3)}", "{fn MOD(-10, 3)}"));
assertEquals(new Values(9.0d, 10, 1, -1), v);
// Belows are floating numbers so comparing this with literal is tend to be failing...
// Picking int value and compare
Values v2 = testExpr(Lists.newArrayList("{fn LOG(16)}", "{fn LOG10(10000)}", "{fn EXP(10)}"));
List<Object> v2m = Lists.transform(v2, new Function<Object, Object>() {
@Nullable
@Override
public Object apply(@Nullable Object o) {
// only takes int value
return ((Number) o).intValue();
}
});
// 2.7725, 4.0, 22026.465794
assertEquals(new Values(2, 4, 22026), v2m);
}
use of javax.annotation.Nullable in project Store by NYTimes.
the class BreadthFirstFileTreeIterator method findNextFile.
/**
* Find the next file.
*
* @return The next file
*/
@Nullable
protected File findNextFile() {
while (currentIndex < currentList.length) {
if (currentList[currentIndex].isDirectory()) {
directories.push(currentList[currentIndex]);
currentIndex++;
} else {
File file = currentList[currentIndex];
currentIndex++;
return file;
}
}
while (!directories.empty()) {
File directory = directories.remove(0);
currentList = directory.listFiles();
currentIndex = 0;
File file = findNextFile();
if (file != null) {
return file;
}
}
endOfTree = true;
return null;
}
use of javax.annotation.Nullable in project MinecraftForge by MinecraftForge.
the class ModelBlockAnimation method getPartTransform.
@Nullable
public TRSRTransformation getPartTransform(IModelState state, BlockPart part, int i) {
ImmutableCollection<MBJointWeight> infos = getJoint(i);
if (!infos.isEmpty()) {
Matrix4f m = new Matrix4f(), tmp;
float weight = 0;
for (MBJointWeight info : infos) {
if (info.getWeights().containsKey(i)) {
ModelBlockAnimation.MBJoint joint = new ModelBlockAnimation.MBJoint(info.getName(), part);
Optional<TRSRTransformation> trOp = state.apply(Optional.of(joint));
if (trOp.isPresent() && trOp.get() != TRSRTransformation.identity()) {
float w = info.getWeights().get(i)[0];
tmp = trOp.get().getMatrix();
tmp.mul(w);
m.add(tmp);
weight += w;
}
}
}
if (weight > 1e-5) {
m.mul(1f / weight);
return new TRSRTransformation(m);
}
}
return null;
}
use of javax.annotation.Nullable in project MinecraftForge by MinecraftForge.
the class FluidUtil method getFluidHandler.
/**
* Helper method to get an IFluidHandler for at a block position.
*
* Returns null if there is no valid fluid handler.
*/
@Nullable
public static IFluidHandler getFluidHandler(World world, BlockPos blockPos, @Nullable EnumFacing side) {
IBlockState state = world.getBlockState(blockPos);
Block block = state.getBlock();
if (block.hasTileEntity(state)) {
TileEntity tileEntity = world.getTileEntity(blockPos);
if (tileEntity != null && tileEntity.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side)) {
return tileEntity.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side);
}
} else if (block instanceof IFluidBlock) {
return new FluidBlockWrapper((IFluidBlock) block, world, blockPos);
} else if (block instanceof BlockLiquid) {
return new BlockLiquidWrapper((BlockLiquid) block, world, blockPos);
}
return null;
}
use of javax.annotation.Nullable in project MinecraftForge by MinecraftForge.
the class ForgeChunkManager method requestTicket.
/**
* Request a chunkloading ticket of the appropriate type for the supplied mod
*
* @param mod The mod requesting a ticket
* @param world The world in which it is requesting the ticket
* @param type The type of ticket
* @return A ticket with which to register chunks for loading, or null if no further tickets are available
*/
@Nullable
public static Ticket requestTicket(Object mod, World world, Type type) {
ModContainer container = getContainer(mod);
if (container == null) {
FMLLog.log(Level.ERROR, "Failed to locate the container for mod instance %s (%s : %x)", mod, mod.getClass().getName(), System.identityHashCode(mod));
return null;
}
String modId = container.getModId();
if (!callbacks.containsKey(modId)) {
FMLLog.severe("The mod %s has attempted to request a ticket without a listener in place", modId);
throw new RuntimeException("Invalid ticket request");
}
int allowedCount = getMaxTicketLengthFor(modId);
if (tickets.get(world).get(modId).size() >= allowedCount) {
if (!warnedMods.contains(modId)) {
FMLLog.info("The mod %s has attempted to allocate a chunkloading ticket beyond it's currently allocated maximum : %d", modId, allowedCount);
warnedMods.add(modId);
}
return null;
}
Ticket ticket = new Ticket(modId, type, world);
tickets.get(world).put(modId, ticket);
return ticket;
}
Aggregations