本文整理汇总了Java中org.apache.commons.lang3.mutable.MutableBoolean类的典型用法代码示例。如果您正苦于以下问题:Java MutableBoolean类的具体用法?Java MutableBoolean怎么用?Java MutableBoolean使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MutableBoolean类属于org.apache.commons.lang3.mutable包,在下文中一共展示了MutableBoolean类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.apache.commons.lang3.mutable.MutableBoolean; //导入依赖的package包/类
@Override
protected ActivityResultContext execute() throws Exception {
// on attend sur un lock, si nécessaire
final String lockKey = getStringVariable(WAIT_LOCK_KEY);
if (lockKey != null) {
final MutableBoolean lock = (MutableBoolean) datastore.get(lockKey);
if (lock != null) {
//noinspection SynchronizationOnLocalVariableOrMethodParameter
synchronized (lock) {
while (lock.booleanValue()) {
lock.wait();
}
}
}
}
// on stocke un pseudo-résultat dans le datastore global (pour simuler la database dans le cas ordinaire)
final String key = getStringVariable(RESULTS_KEY);
datastore.put(key, true);
return new FinishedActivityResultContext();
}
示例2: testCallTwice
import org.apache.commons.lang3.mutable.MutableBoolean; //导入依赖的package包/类
@Test
public void testCallTwice() throws Exception {
final MutableInt callCount = new MutableInt(0);
final MutableBoolean called = new MutableBoolean(false);
Polling p = new Polling() {
@Override
public Boolean call() throws Exception {
callCount.increment();
boolean b = called.booleanValue();
called.setTrue();
return b;
}
};
p.poll(500, 10);
assertEquals(2, callCount.intValue());
}
示例3: testCallableTwice
import org.apache.commons.lang3.mutable.MutableBoolean; //导入依赖的package包/类
@Test
public void testCallableTwice() throws Exception {
final MutableInt callCount = new MutableInt(0);
final MutableBoolean called = new MutableBoolean(false);
Polling p = new Polling(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
callCount.increment();
boolean b = called.booleanValue();
called.setTrue();
return b;
}
});
p.poll(500, 10);
assertEquals(2, callCount.intValue());
}
示例4: test
import org.apache.commons.lang3.mutable.MutableBoolean; //导入依赖的package包/类
@Test
public void test() throws IOException {
MutableBoolean parsed = new MutableBoolean(false);
AsyncJsonParser parser = new AsyncJsonParser(root -> {
parsed.setValue(true);
try {
Assert.assertEquals(mapper.treeToValue(root, Model.class), model);
} catch (JsonProcessingException e) {
Assert.fail(e.getMessage());
}
});
for (byte b : new ObjectMapper().writeValueAsBytes(model)) {
parser.consume(new byte[] { b }, 1);
}
Assert.assertTrue(parsed.booleanValue());
}
示例5: test_chunks
import org.apache.commons.lang3.mutable.MutableBoolean; //导入依赖的package包/类
@Test
public void test_chunks() throws IOException {
MutableBoolean parsed = new MutableBoolean(false);
AsyncJsonParser parser = new AsyncJsonParser(root -> {
parsed.setValue(true);
try {
Assert.assertEquals(mapper.treeToValue(root, Model.class), model);
} catch (JsonProcessingException e) {
Assert.fail(e.getMessage());
}
});
final int CHUNK_SIZE = 20;
byte[] bytes = new ObjectMapper().writeValueAsBytes(model);
for (int i = 0; i < bytes.length; i += CHUNK_SIZE) {
byte[] chunk = new byte[20];
int start = Math.min(bytes.length, i);
int len = Math.min(CHUNK_SIZE, bytes.length - i);
System.arraycopy(bytes, start, chunk, 0, len);
parser.consume(chunk, len);
}
Assert.assertTrue(parsed.booleanValue());
}
示例6: determineDeleteInBatchSupported
import org.apache.commons.lang3.mutable.MutableBoolean; //导入依赖的package包/类
private boolean determineDeleteInBatchSupported(final Class<?> genericType) {
final MutableBoolean deleteInBatchSupported = new MutableBoolean(true);
Reflections.doWithFields(genericType, new FieldCallback() {
@Override
public void doWith(final Field field) {
if (!deleteInBatchSupported.getValue()) {
return;
} else if (Reflections.getAnnotation(field, ElementCollection.class) != null) {
//element collections are mapped as separate tables, thus the values would cause a foreign key constraint violation
deleteInBatchSupported.setValue(false);
} else if (Reflections.getAnnotation(field, Embedded.class) != null) {
//check embedded types for the same constraints
if (!determineDeleteInBatchSupported(field.getType())) {
deleteInBatchSupported.setValue(false);
}
}
}
});
return deleteInBatchSupported.getValue();
}
示例7: firstDoneTest
import org.apache.commons.lang3.mutable.MutableBoolean; //导入依赖的package包/类
@Test
public void firstDoneTest()
{
SimpleDoneQueueManager<Query, Void> sdqqm = new SimpleDoneQueueManager<Query, Void>();
sdqqm.setup(null);
sdqqm.beginWindow(0);
Query query = new MockQuery("1");
sdqqm.enqueue(query, null, new MutableBoolean(true));
QueryBundle<Query, Void, MutableBoolean> qb = sdqqm.dequeue();
Assert.assertEquals("Should return back null.", null, qb);
sdqqm.endWindow();
sdqqm.beginWindow(1);
qb = sdqqm.dequeue();
Assert.assertEquals("Should return back null.", null, qb);
qb = sdqqm.dequeue();
Assert.assertEquals("Should return back null.", null, qb);
sdqqm.endWindow();
sdqqm.teardown();
}
示例8: simpleEnqueueDequeueBlock
import org.apache.commons.lang3.mutable.MutableBoolean; //导入依赖的package包/类
@Test
public void simpleEnqueueDequeueBlock()
{
SimpleDoneQueueManager<Query, Void> sdqqm = new SimpleDoneQueueManager<Query, Void>();
sdqqm.setup(null);
sdqqm.beginWindow(0);
Query query = new MockQuery("1");
sdqqm.enqueue(query, null, new MutableBoolean(false));
Assert.assertEquals(1, sdqqm.getNumLeft());
Assert.assertEquals(sdqqm.getNumPermits(), sdqqm.getNumLeft());
QueryBundle<Query, Void, MutableBoolean> qb = sdqqm.dequeueBlock();
Assert.assertEquals(0, sdqqm.getNumLeft());
Assert.assertEquals(sdqqm.getNumPermits(), sdqqm.getNumLeft());
Assert.assertEquals("Should return same query.", query, qb.getQuery());
sdqqm.endWindow();
sdqqm.teardown();
}
示例9: simpleEnqueueDequeueThenBlock
import org.apache.commons.lang3.mutable.MutableBoolean; //导入依赖的package包/类
@Test
public void simpleEnqueueDequeueThenBlock() throws Exception
{
SimpleDoneQueueManager<Query, Void> sdqqm = new SimpleDoneQueueManager<Query, Void>();
sdqqm.setup(null);
sdqqm.beginWindow(0);
Query query = new MockQuery("1");
sdqqm.enqueue(query, null, new MutableBoolean(false));
Assert.assertEquals(1, sdqqm.getNumLeft());
Assert.assertEquals(sdqqm.getNumPermits(), sdqqm.getNumLeft());
QueryBundle<Query, Void, MutableBoolean> qb = sdqqm.dequeueBlock();
Assert.assertEquals(0, sdqqm.getNumLeft());
Assert.assertEquals(sdqqm.getNumPermits(), sdqqm.getNumLeft());
testBlocking(sdqqm);
sdqqm.endWindow();
sdqqm.teardown();
}
示例10: isBlank
import org.apache.commons.lang3.mutable.MutableBoolean; //导入依赖的package包/类
@Override
public boolean isBlank() {
CsvGridSheetPane gridSheet = getGridSheet();
MutableBoolean result = new MutableBoolean(true);
forEachCell(new ICellConsumer() {
@Override
public boolean accept(int r, int c) {
Object val = gridSheet.getValueAt(r, c);
if (val != null && !val.toString().isEmpty()) {
result.setFalse();
return false;
}
return true;
}
});
return result.booleanValue();
}
示例11: decodeString
import org.apache.commons.lang3.mutable.MutableBoolean; //导入依赖的package包/类
private String decodeString(ByteBuf in) throws ProtocolException {
final StringBuilder buffer = new StringBuilder();
final MutableBoolean reachCRLF = new MutableBoolean(false);
setReaderIndex(in, in.forEachByte(new ByteBufProcessor() {
@Override
public boolean process(byte value) throws Exception {
if (value == '\n') {
if ((byte) buffer.charAt(buffer.length() - 1) != '\r') {
throw new ProtocolException("Response is not ended by CRLF");
} else {
buffer.setLength(buffer.length() - 1);
reachCRLF.setTrue();
return false;
}
} else {
buffer.append((char) value);
return true;
}
}
}));
return reachCRLF.booleanValue() ? buffer.toString() : null;
}
示例12: toRangeClause
import org.apache.commons.lang3.mutable.MutableBoolean; //导入依赖的package包/类
private String toRangeClause(SqlgGraph sqlgGraph, MutableBoolean mutableOrderBy) {
if (this.sqlgRangeHolder != null && this.sqlgRangeHolder.isApplyOnDb()) {
if (this.sqlgRangeHolder.hasRange()) {
//This is MssqlServer, ugly but what to do???
String sql = "";
if (mutableOrderBy.isFalse() && sqlgGraph.getSqlDialect().isMssqlServer() && this.getDbComparators().isEmpty()) {
sql = "\n\tORDER BY 1\n\t";
}
return sql + "\n" + sqlgGraph.getSqlDialect().getRangeClause(this.sqlgRangeHolder.getRange());
} else {
Preconditions.checkState(this.sqlgRangeHolder.hasSkip(), "If not a range query then it must be a skip.");
return sqlgGraph.getSqlDialect().getSkipClause(this.sqlgRangeHolder.getSkip());
}
}
return "";
}
示例13: onPunish
import org.apache.commons.lang3.mutable.MutableBoolean; //导入依赖的package包/类
private static void onPunish(Session session, String ... args) {
if (args.length < 2) return;
if (PlayerInfo.isModerator(session.getPlayerId())) {
int targetId = CharacterUtils.getCharacterIdByName(args[1]);
MutableBoolean targetFound = new MutableBoolean(false);
ServerManager.getSession(targetId).ifPresent(target -> {
ChatUtils.sendServerMessage(target, "You have been punished by a moderator.");
target.close();
ChatUtils.sendServerMessage(session, "Player punished: " + args[1]);
targetFound.setTrue();
});
if (targetFound.isFalse()) {
ChatUtils.sendServerMessage(session, "Player not found.");
}
}
}
示例14: clearFilters
import org.apache.commons.lang3.mutable.MutableBoolean; //导入依赖的package包/类
@Test
public void clearFilters() {
final List<Person> listOfPersons = getListOfPersons(100);
FilterableListContainer<Person> container = new FilterableListContainer<>(
listOfPersons);
container.addContainerFilter(new SimpleStringFilter("firstName",
"First1", true, true));
Assert.assertNotSame(listOfPersons.size(), container.size());
container.removeAllContainerFilters();
Assert.assertEquals(listOfPersons.size(), container.size());
container.addContainerFilter(new SimpleStringFilter("firstName",
"foobar", true, true));
Assert.assertEquals(0, container.size());
final MutableBoolean fired = new MutableBoolean(false);
container.addListener(new Container.ItemSetChangeListener() {
@Override
public void containerItemSetChange(
Container.ItemSetChangeEvent event) {
fired.setTrue();
}
});
container.removeAllContainerFilters();
Assert.assertTrue(fired.booleanValue());
Assert.assertEquals(listOfPersons.size(), container.size());
}
示例15: of
import org.apache.commons.lang3.mutable.MutableBoolean; //导入依赖的package包/类
private static <T> VlanAllocation of(Collection<T> ports, Function<T, Optional<Integer>> sVlanId, Function<T, Optional<Vlan>> vlan) {
MutableBoolean overlappingVlan = new MutableBoolean(false);
Map<Optional<Integer>, Vlan> allocationsPerSVlan = ports.stream().collect(Collectors.toMap(
sVlanId,
port -> vlan.apply(port).orElse(Vlan.none()),
(a, b) -> {
if (a.overlaps(b)) {
overlappingVlan.setTrue();
}
return a.union(b);
}));
Vlan allocatedSVlans = ports.stream()
.map(port -> sVlanId.apply(port).map(Vlan::singleton).orElse(Vlan.none()))
.reduce(Vlan.none(), Vlan::union);
if (!overlappingVlan.booleanValue() && allocatedSVlans.overlaps(allocationsPerSVlan.getOrDefault(Optional.empty(), Vlan.none()))) {
overlappingVlan.setTrue();
};
return new VlanAllocation(overlappingVlan.booleanValue(), allocationsPerSVlan, allocatedSVlans);
}