本文整理汇总了Java中scala.runtime.BoxedUnit.UNIT属性的典型用法代码示例。如果您正苦于以下问题:Java BoxedUnit.UNIT属性的具体用法?Java BoxedUnit.UNIT怎么用?Java BoxedUnit.UNIT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类scala.runtime.BoxedUnit
的用法示例。
在下文中一共展示了BoxedUnit.UNIT属性的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: letOverridesDefault
@Test public void letOverridesDefault() {
final String override = "localhost:9410";
final AtomicBoolean ran = new AtomicBoolean();
Function0<BoxedUnit> fn0 = new AbstractFunction0<BoxedUnit>() {
@Override public BoxedUnit apply() {
ran.set(true); // used to verify this block is executed.
assertThat(host$.Flag.isDefined()).isTrue();
assertThat(host$.Flag.apply()).isEqualTo(override);
return BoxedUnit.UNIT;
}
};
host$.Flag.let(override, fn0);
assertThat(ran.get()).isTrue();
}
示例2: letOverridesDefault
@Test public void letOverridesDefault() {
final String override = "amazon";
final AtomicBoolean ran = new AtomicBoolean();
Function0<BoxedUnit> fn0 = new AbstractFunction0<BoxedUnit>() {
@Override public BoxedUnit apply() {
ran.set(true); // used to verify this block is executed.
assertThat(hostHeader$.Flag.isDefined()).isTrue();
assertThat(hostHeader$.Flag.apply()).isEqualTo(override);
return BoxedUnit.UNIT;
}
};
hostHeader$.Flag.let(override, fn0);
assertThat(ran.get()).isTrue();
}
示例3: letOverridesDefault
@Test public void letOverridesDefault() {
final String override = "foo:9411";
final AtomicBoolean ran = new AtomicBoolean();
Function0<BoxedUnit> fn0 = new AbstractFunction0<BoxedUnit>() {
@Override public BoxedUnit apply() {
ran.set(true); // used to verify this block is executed.
assertThat(host$.Flag.isDefined()).isTrue();
assertThat(host$.Flag.apply()).isEqualTo(override);
return BoxedUnit.UNIT;
}
};
host$.Flag.let(override, fn0);
assertThat(ran.get()).isTrue();
}
示例4: letOverridesDefault
@Test public void letOverridesDefault() {
final boolean override = false;
final AtomicBoolean ran = new AtomicBoolean();
Function0<BoxedUnit> fn0 = new AbstractFunction0<BoxedUnit>() {
@Override public BoxedUnit apply() {
ran.set(true); // used to verify this block is executed.
assertThat(compressionEnabled$.Flag.isDefined()).isTrue();
assertThat(compressionEnabled$.Flag.apply()).isEqualTo(override);
return BoxedUnit.UNIT;
}
};
compressionEnabled$.Flag.let(override, fn0);
assertThat(ran.get()).isTrue();
}
示例5: letOverridesDefault
@Test public void letOverridesDefault() {
final float override = 1.0f;
final AtomicBoolean ran = new AtomicBoolean();
Function0<BoxedUnit> fn0 = new AbstractFunction0<BoxedUnit>() {
@Override public BoxedUnit apply() {
ran.set(true); // used to verify this block is executed.
assertThat(initialSampleRate$.Flag.isDefined()).isTrue();
assertThat(initialSampleRate$.Flag.apply()).isEqualTo(override);
return BoxedUnit.UNIT;
}
};
initialSampleRate$.Flag.let(override, fn0);
assertThat(ran.get()).isTrue();
}
示例6: letOverridesDefault
@Test public void letOverridesDefault() {
final String override = "zipkin-dev";
final AtomicBoolean ran = new AtomicBoolean();
Function0<BoxedUnit> fn0 = new AbstractFunction0<BoxedUnit>() {
@Override public BoxedUnit apply() {
ran.set(true); // used to verify this block is executed.
assertThat(topic$.Flag.isDefined()).isTrue();
assertThat(topic$.Flag.apply()).isEqualTo(override);
return BoxedUnit.UNIT;
}
};
topic$.Flag.let(override, fn0);
assertThat(ran.get()).isTrue();
}
示例7: letOverridesDefault
@Test public void letOverridesDefault() {
final List<InetSocketAddress> override = singletonList(new InetSocketAddress("zipkin", 9092));
final AtomicBoolean ran = new AtomicBoolean();
Function0<BoxedUnit> fn0 = new AbstractFunction0<BoxedUnit>() {
@Override public BoxedUnit apply() {
ran.set(true); // used to verify this block is executed.
assertThat(bootstrapServers$.Flag.isDefined()).isTrue();
assertThat(bootstrapServers$.Flag.apply()).isEqualTo(override);
return BoxedUnit.UNIT;
}
};
bootstrapServers$.Flag.let(override, fn0);
assertThat(ran.get()).isTrue();
}
示例8: createLock
@Override
public Future<SessionLock> createLock(String lockPath,
DistributedLockContext context) {
AtomicInteger numRetries = new AtomicInteger(lockCreationRetries);
final AtomicReference<Throwable> interruptedException = new AtomicReference<Throwable>(null);
Promise<SessionLock> createPromise =
new Promise<SessionLock>(new com.twitter.util.Function<Throwable, BoxedUnit>() {
@Override
public BoxedUnit apply(Throwable t) {
interruptedException.set(t);
return BoxedUnit.UNIT;
}
});
createLock(
lockPath,
context,
interruptedException,
numRetries,
createPromise,
0L);
return createPromise;
}
示例9: addCallback
/**
* Build a midas client, then bind session file
* and callbacks.
*
* @param client a midas client need to be constructed,
* could be a normal client and a sharable
* client;
*/
private void addCallback(MidasClient client) {
final RemoteResultDisplay display = RapidMinerGUI.getMainFrame().getRemoteResultDisplay();
// add callbacks
Function1<JobStatus, BoxedUnit> fn = new AbstractFunction1<JobStatus, BoxedUnit>() {
@Override
public BoxedUnit apply(JobStatus v1) {
final RemoteResultOverview overview = display.getOverview();
final JobStatus status = v1;
boolean msg = overview.updateStatus(status);
if (msg) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
// Scroll to the bottom when job finished.
Rectangle visibleRect = overview.getVisibleRect();
visibleRect.y = overview.getHeight() - visibleRect.height;
overview.scrollRectToVisible(visibleRect);
if (!OperatorService.isRapidGUITestMode()) {
// User should be toggled to result page when click `ok` in finish panel.
switch(SwingTools.showConfirmDialog("job_finished",
ConfirmDialog.OK_CANCEL_OPTION, status.session().id(), status.id())) {
case ConfirmDialog.OK_OPTION:
overview.showStatusResult(status);
break;
}
}
}
});
}
return BoxedUnit.UNIT;
}
};
client.addCompleteCallback(fn);
}
示例10: submit
<T> Function1<T, BoxedUnit> submit(final Function1<T, BoxedUnit> function) {
return new AbstractFunction1<T, BoxedUnit>() {
@Override
public BoxedUnit apply(final T input) {
submit(new Runnable() {
@Override
public void run() {
function.apply(input);
}
});
return BoxedUnit.UNIT;
}
};
}
示例11: respondToChanges
private BoxedUnit respondToChanges(Addr addr) {
ImmutableSet<ServiceInstance> oldHostSet = ImmutableSet.copyOf(hostSet);
ImmutableSet<ServiceInstance> newHostSet = oldHostSet;
if (addr instanceof Addr.Bound) {
scala.collection.immutable.Set<Address> endpointAddresses = ((Addr.Bound)addr).addrs();
scala.collection.Iterator<Address> endpointAddressesIterator = endpointAddresses.toIterator();
HashSet<ServiceInstance> serviceInstances = new HashSet<ServiceInstance>();
while (endpointAddressesIterator.hasNext()) {
serviceInstances.add(endpointAddressToServiceInstance(endpointAddressesIterator.next()));
}
newHostSet = ImmutableSet.copyOf(serviceInstances);
} else if (addr instanceof Addr.Failed) {
logger.error("Name resolution failed", ((Addr.Failed)addr).cause());
newHostSet = ImmutableSet.of();
} else if (addr.toString().equals("Pending")) {
logger.info("Name resolution pending");
newHostSet = oldHostSet;
} else if (addr.toString().equals("Neg")) {
newHostSet = ImmutableSet.of();
} else {
logger.error("Invalid Addr type: {}", addr.getClass().getName());
throw new UnsupportedOperationException("Invalid Addr type:" + addr.getClass().getName());
}
// Reference comparison is valid as the sets are immutable
if (oldHostSet != newHostSet) {
logger.info("NameServerSet updated: {} -> {}", hostSetToString(oldHostSet), hostSetToString(newHostSet));
resolutionPending.set(false);
hostSet = newHostSet;
synchronized (watchers) {
for (HostChangeMonitor<ServiceInstance> watcher: watchers) {
watcher.onChange(newHostSet);
}
}
}
return BoxedUnit.UNIT;
}
示例12: ZKSessionLock
/**
* Creates a distributed lock using the given {@code zkClient} to coordinate locking.
*
* @param zkClient The ZooKeeper client to use.
* @param lockPath The path used to manage the lock under.
* @param clientId client id use for lock.
* @param lockStateExecutor executor to execute all lock state changes.
* @param lockOpTimeout timeout of lock operations
* @param statsLogger stats logger
*/
public ZKSessionLock(ZooKeeperClient zkClient,
String lockPath,
String clientId,
OrderedScheduler lockStateExecutor,
long lockOpTimeout,
StatsLogger statsLogger,
DistributedLockContext lockContext)
throws IOException {
this.zkClient = zkClient;
try {
this.zk = zkClient.get();
} catch (ZooKeeperClient.ZooKeeperConnectionException zce) {
throw new ZKException("Failed to get zookeeper client for lock " + lockPath,
KeeperException.Code.CONNECTIONLOSS);
} catch (InterruptedException e) {
throw new DLInterruptedException("Interrupted on getting zookeeper client for lock " + lockPath, e);
}
this.lockPath = lockPath;
this.lockId = Pair.of(clientId, this.zk.getSessionId());
this.lockContext = lockContext;
this.lockStateExecutor = lockStateExecutor;
this.lockState = new StateManagement();
this.lockOpTimeout = lockOpTimeout;
this.tryStats = statsLogger.getOpStatsLogger("tryAcquire");
this.tryTimeouts = statsLogger.getCounter("tryTimeouts");
this.unlockStats = statsLogger.getOpStatsLogger("unlock");
// Attach interrupt handler to acquire future so clients can abort the future.
this.acquireFuture = new Promise<Boolean>(new com.twitter.util.Function<Throwable, BoxedUnit>() {
@Override
public BoxedUnit apply(Throwable t) {
// This will set the lock state to closed, and begin to cleanup the zk lock node.
// We have to be careful not to block here since doing so blocks the ordered lock
// state executor which can cause deadlocks depending on how futures are chained.
ZKSessionLock.this.asyncUnlock(t);
// Note re. logging and exceptions: errors are already logged by unlockAsync.
return BoxedUnit.UNIT;
}
});
}
示例13: apply
@Override
public BoxedUnit apply(Throwable cause) {
interrupted = true;
return BoxedUnit.UNIT;
}
示例14: apply
@Override
public BoxedUnit apply(EdgeContext<String, String, Integer> arg0) {
arg0.sendToDst(1);
return BoxedUnit.UNIT;
}