org.apache.commons.lang3.mutable.MutableBoolean类的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(10.2k)|赞(0)|评价(0)|浏览(155)

本文整理了Java中org.apache.commons.lang3.mutable.MutableBoolean类的一些代码示例,展示了MutableBoolean类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MutableBoolean类的具体详情如下:
包路径:org.apache.commons.lang3.mutable.MutableBoolean
类名称:MutableBoolean

MutableBoolean介绍

[英]A mutable boolean wrapper.

Note that as MutableBoolean does not extend Boolean, it is not treated by String.format as a Boolean parameter.
[中]一个可变的boolean包装器。
请注意,由于MutableBoolean不扩展Boolean,所以它不被字符串处理。格式为布尔参数。

代码示例

代码示例来源:origin: org.apache.commons/commons-lang3

@Test
public void testGetSet() {
  assertFalse(new MutableBoolean().booleanValue());
  assertEquals(Boolean.FALSE, new MutableBoolean().getValue());
  final MutableBoolean mutBool = new MutableBoolean(false);
  assertEquals(Boolean.FALSE, mutBool.toBoolean());
  assertFalse(mutBool.booleanValue());
  assertTrue(mutBool.isFalse());
  assertFalse(mutBool.isTrue());
  mutBool.setValue(Boolean.TRUE);
  assertEquals(Boolean.TRUE, mutBool.toBoolean());
  assertTrue(mutBool.booleanValue());
  assertFalse(mutBool.isFalse());
  assertTrue(mutBool.isTrue());
  mutBool.setValue(false);
  assertFalse(mutBool.booleanValue());
  mutBool.setValue(true);
  assertTrue(mutBool.booleanValue());
  mutBool.setFalse();
  assertFalse(mutBool.booleanValue());
  mutBool.setTrue();
  assertTrue(mutBool.booleanValue());
}

代码示例来源:origin: apache/hbase

/**
 * Check to see if the client should try to connnect to the server, inspite of
 * knowing that it is in the fast fail mode.
 *
 * The idea here is that we want just one client thread to be actively trying
 * to reconnect, while all the other threads trying to reach the server will
 * short circuit.
 *
 * @param fInfo
 * @return true if the client should try to connect to the server.
 */
protected boolean shouldRetryInspiteOfFastFail(FailureInfo fInfo) {
 // We believe that the server is down, But, we want to have just one
 // client
 // actively trying to connect. If we are the chosen one, we will retry
 // and not throw an exception.
 if (fInfo != null
   && fInfo.exclusivelyRetringInspiteOfFastFail.compareAndSet(false, true)) {
  MutableBoolean threadAlreadyInFF = this.threadRetryingInFastFailMode
    .get();
  if (threadAlreadyInFF == null) {
   threadAlreadyInFF = new MutableBoolean();
   this.threadRetryingInFastFailMode.set(threadAlreadyInFF);
  }
  threadAlreadyInFF.setValue(true);
  return true;
 } else {
  return false;
 }
}

代码示例来源:origin: org.apache.commons/commons-lang3

@Test
public void testCompareTo() {
  final MutableBoolean mutBool = new MutableBoolean(false);
  assertEquals(0, mutBool.compareTo(new MutableBoolean(false)));
  assertEquals(-1, mutBool.compareTo(new MutableBoolean(true)));
  mutBool.setValue(true);
  assertEquals(+1, mutBool.compareTo(new MutableBoolean(false)));
  assertEquals(0, mutBool.compareTo(new MutableBoolean(true)));
}

代码示例来源:origin: org.apache.commons/commons-lang3

@Test(expected=NullPointerException.class)
public void testCompareToNull() {
  final MutableBoolean mutBool = new MutableBoolean(false);
  mutBool.compareTo(null);
}

代码示例来源:origin: neo4j/neo4j

/**
 * @return true if instantiated tree needs to be rebuilt.
 */
private boolean instantiateTree() throws IOException
{
  monitors.addMonitorListener( treeMonitor() );
  GBPTree.Monitor monitor = monitors.newMonitor( GBPTree.Monitor.class );
  MutableBoolean isRebuilding = new MutableBoolean();
  Header.Reader readRebuilding =
      headerData -> isRebuilding.setValue( headerData.get() == NEEDS_REBUILDING );
  index = new GBPTree<>( pageCache, storeFile, new LabelScanLayout(), pageSize, monitor, readRebuilding,
      needsRebuildingWriter, recoveryCleanupWorkCollector );
  return isRebuilding.getValue();
}

代码示例来源:origin: neo4j/neo4j

private void logIndexProviderSummary( Map<IndexProviderDescriptor,List<IndexLogRecord>> indexProviders )
{
  Set<String> deprecatedIndexProviders = Arrays.stream( GraphDatabaseSettings.SchemaIndex.values() )
      .filter( GraphDatabaseSettings.SchemaIndex::deprecated )
      .map( GraphDatabaseSettings.SchemaIndex::providerName )
      .collect( Collectors.toSet() );
  StringJoiner joiner = new StringJoiner( ", ", "Deprecated index providers in use: ",
      ". Use procedure 'db.indexes()' to see what indexes use which index provider." );
  MutableBoolean anyDeprecated = new MutableBoolean();
  indexProviders.forEach( ( indexProviderDescriptor, indexLogRecords ) ->
  {
    if ( deprecatedIndexProviders.contains( indexProviderDescriptor.name() ) )
    {
      anyDeprecated.setTrue();
      int numberOfIndexes = indexLogRecords.size();
      joiner.add( indexProviderDescriptor.name() + " (" + numberOfIndexes + (numberOfIndexes == 1 ? " index" : " indexes") + ")" );
    }
  } );
  if ( anyDeprecated.getValue() )
  {
    userLog.info( joiner.toString() );
  }
}

代码示例来源:origin: org.apache.commons/commons-lang3

@Test
public void testConstructors() {
  assertFalse(new MutableBoolean().booleanValue());
  assertTrue(new MutableBoolean(true).booleanValue());
  assertFalse(new MutableBoolean(false).booleanValue());
  assertTrue(new MutableBoolean(Boolean.TRUE).booleanValue());
  assertFalse(new MutableBoolean(Boolean.FALSE).booleanValue());
}

代码示例来源:origin: org.apache.commons/commons-lang3

/**
 * Compares this object to the specified object. The result is <code>true</code> if and only if the argument is
 * not <code>null</code> and is an <code>MutableBoolean</code> object that contains the same
 * <code>boolean</code> value as this object.
 *
 * @param obj  the object to compare with, null returns false
 * @return <code>true</code> if the objects are the same; <code>false</code> otherwise.
 */
@Override
public boolean equals(final Object obj) {
  if (obj instanceof MutableBoolean) {
    return value == ((MutableBoolean) obj).booleanValue();
  }
  return false;
}

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core

@Override
public boolean validate(Object value, Object context) {
  MutableBoolean validated = new MutableBoolean();
  resolve(value, context, (session, docRef) -> {
    if (session.exists(docRef)) {
      validated.setTrue();
    }
  });
  return validated.isTrue();
}

代码示例来源:origin: io.ultreia.gc/gc-api

private Map<String, GcDistrict> acquireDistricts(String geonamesUser, Set<GcCacheRefWithCoordinates> cacheRefWithCoordinates, Set<GcCacheRefWithCoordinates> badGcs) {
  int badGcSize = badGcs.size();
  int size = cacheRefWithCoordinates.size();
  log.info(String.format("Found %s french cache(s).", size));
  MutableInt i = new MutableInt();
  MutableBoolean b = new MutableBoolean();
  Map<String, GcDistrict> toUpdate = new TreeMap<>();
  cacheRefWithCoordinates.parallelStream().forEach(cacheRefWithCoordinate -> {
    if (b.booleanValue()) {
      return;
    }
    log.info(String.format("[%d/%d] Update district for cache %s", i.incrementAndGet(), size, cacheRefWithCoordinate.getGcName()));
    try {
      Optional<GcDistrict> gcDistrict = updateDistrict(geonamesUser, cacheRefWithCoordinate);
      if (gcDistrict.isPresent()) {
        toUpdate.put(cacheRefWithCoordinate.getId(), gcDistrict.get());
      } else {
        badGcs.add(cacheRefWithCoordinate);
      }
      gcDistrict.ifPresent(d -> toUpdate.put(cacheRefWithCoordinate.getId(), d));
    } catch (Exception e) {
      log.error("Could not get district for cache " + cacheRefWithCoordinate.getGcName(), e);
      b.setTrue();
    }
  });
  if (badGcs.size() > badGcSize) {
    storeBadDistrictGcs(badGcs);
  }
  return toUpdate;
}

代码示例来源:origin: apache/hbase

final HRegion region = (HRegion) rs.getRegions(tableName).get(0);
HRegion spiedRegion = spy(region);
final MutableBoolean flushed = new MutableBoolean(false);
final MutableBoolean reported = new MutableBoolean(false);
doAnswer(new Answer<FlushResult>() {
 @Override
rs.cacheFlusher.requestFlush(spiedRegion, false, FlushLifeCycleTracker.DUMMY);
synchronized (flushed) {
 while (!flushed.booleanValue()) {
  flushed.wait();
rs.tryRegionServerReport(now - 500, now);
synchronized (reported) {
 reported.setValue(true);
 reported.notifyAll();

代码示例来源:origin: com.atlassian.diagnostics/atlassian-diagnostics-core

requireNonNull(pageRequest, "pageRequest");
MutableBoolean done = new MutableBoolean(false);
MutableInt emittedRow = new MutableInt(0);
MutableInt entityRow = new MutableInt(0);
try {
  callback.onStart(pageRequest);
  while (done.isFalse() && emittedRow.getValue() <= end) {
    transactionTemplate.execute(() -> {
      MutableInt pageSize = new MutableInt(0);
          if (row >= start && row < end) {
            if (callback.onItem(alertCount) == DONE) {
              done.setTrue();
        done.setValue(done.isTrue() || emittedRow.getValue() > end);
        return done.isTrue() ? DONE : CONTINUE;
      }, PageRequest.of(entityRow.getValue(), daoPageSize));
      done.setValue(done.isTrue() || pageSize.getValue() <= daoPageSize);
      return null;
    });

代码示例来源:origin: apache/hbase

@Override
public void clear() {
 server = null;
 fInfo = null;
 didTry = false;
 couldNotCommunicateWithServer.setValue(false);
 guaranteedClientSideOnly.setValue(false);
 retryDespiteFastFailMode = false;
 tries = 0;
}

代码示例来源:origin: apache/hbase

@Override
 public FlushResult answer(InvocationOnMock invocation) throws Throwable {
  synchronized (flushed) {
   flushed.setValue(true);
   flushed.notifyAll();
  }
  synchronized (reported) {
   while (!reported.booleanValue()) {
    reported.wait();
   }
  }
  rs.getWAL(region.getRegionInfo()).abortCacheFlush(
   region.getRegionInfo().getEncodedNameAsBytes());
  throw new DroppedSnapshotException("testcase");
 }
}).when(spiedRegion).internalFlushCacheAndCommit(Matchers.<WAL> any(),

代码示例来源:origin: org.umlg/sqlg-core

private String toOptionalLeftJoinWhereClause(SqlgGraph sqlgGraph, MutableBoolean printedWhere) {
  final StringBuilder result = new StringBuilder();
  if (!printedWhere.booleanValue()) {
    printedWhere.setTrue();
    result.append("\nWHERE\n\t(");
  } else {

代码示例来源:origin: org.wso2.carbon.auth/org.wso2.carbon.auth.oauth

private void processAuthCodeGrantRequest(String authorization, AccessTokenContext context,
                     AuthorizationCodeGrant request) throws OAuthDAOException {
  log.debug("Calling processAuthCodeGrantRequest");
  MutableBoolean haltExecution = new MutableBoolean(false);
  String clientId = (String) context.getParams().get(OAuthConstants.CLIENT_ID);
  if (haltExecution.isTrue()) {
    return;
  }
  Scope scope = getScope(clientId, request, context, haltExecution);
  if (haltExecution.isTrue()) {
    return;
  }
  TokenIssuer.generateAccessToken(scope, context);
  AccessTokenData accessTokenData = TokenDataUtil.generateTokenData(context);
  oauthDAO.addAccessTokenInfo(accessTokenData);
}

代码示例来源:origin: neo4j/neo4j

MutableBoolean throwException = new MutableBoolean( true );
FileSystemAbstraction fs = new DelegatingFileSystemAbstraction( this.fs )
  throwException.setFalse();

代码示例来源:origin: kiegroup/jbpm

@Override
  public void afterNodeLeft(ProcessNodeLeftEvent event) {
    // BoundaryEventNodeInstance
    if(signal.equals(event.getNodeInstance().getNodeName())) {
      eventAfterNodeLeftTriggered.setTrue();
    }
  }
});

代码示例来源:origin: apache/hbase

if (retryAfterOutOfOrderException.isTrue()) {
 retryAfterOutOfOrderException.setValue(false);
} else {

代码示例来源:origin: org.apache.commons/commons-lang3

@Test(expected=NullPointerException.class)
public void testConstructorNull() {
  new MutableBoolean(null);
}

相关文章