当前位置: 首页>>代码示例>>Java>>正文


Java MutableInt类代码示例

本文整理汇总了Java中org.apache.commons.lang3.mutable.MutableInt的典型用法代码示例。如果您正苦于以下问题:Java MutableInt类的具体用法?Java MutableInt怎么用?Java MutableInt使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MutableInt类属于org.apache.commons.lang3.mutable包,在下文中一共展示了MutableInt类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testCallTwice

import org.apache.commons.lang3.mutable.MutableInt; //导入依赖的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());
}
 
开发者ID:apache,项目名称:sling-org-apache-sling-testing-clients,代码行数:18,代码来源:PollingTest.java

示例2: testCallTimeout

import org.apache.commons.lang3.mutable.MutableInt; //导入依赖的package包/类
@Test
public void testCallTimeout() throws Exception {
    final MutableInt callCount = new MutableInt(0);
    Polling p = new Polling() {
        @Override
        public Boolean call() throws Exception {
            callCount.increment();
            return false;
        }
    };

    try {
        p.poll(100, 10);
    } catch (TimeoutException e ) {
        assertTrue("Expected to execute call() at least 4 times, got instead only " + callCount.intValue() + " calls",
                callCount.intValue() > 5);
        return;
    }

    fail("Did not reach timeout");
}
 
开发者ID:apache,项目名称:sling-org-apache-sling-testing-clients,代码行数:22,代码来源:PollingTest.java

示例3: testCallableTwice

import org.apache.commons.lang3.mutable.MutableInt; //导入依赖的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());
}
 
开发者ID:apache,项目名称:sling-org-apache-sling-testing-clients,代码行数:18,代码来源:PollingTest.java

示例4: testCallableTimeout

import org.apache.commons.lang3.mutable.MutableInt; //导入依赖的package包/类
@Test
public void testCallableTimeout() throws Exception {
    final MutableInt callCount = new MutableInt(0);
    Polling p = new Polling(new Callable<Boolean>() {
        @Override
        public Boolean call() throws Exception {
            callCount.increment();
            return false;
        }
    });

    try {
        p.poll(100, 10);
    } catch (TimeoutException e ) {
        assertTrue("Expected to execute call() at least 4 times, got instead only " + callCount.intValue() + " calls",
                callCount.intValue() > 5);
        return;
    }

    fail("Did not reach timeout");
}
 
开发者ID:apache,项目名称:sling-org-apache-sling-testing-clients,代码行数:22,代码来源:PollingTest.java

示例5: addProteinSequenceEntry

import org.apache.commons.lang3.mutable.MutableInt; //导入依赖的package包/类
private void addProteinSequenceEntry(Track<Gene> track, final Gene cds, List<ProteinSequenceEntry> proteinSequences,
                                     String aminoAcid, long tripleStartIndex, int newExtendedStart,
                                     final MutableInt aminoAcidCounter) {
    if (tripleStartIndex >= track.getStartIndex() && tripleStartIndex <= track.getEndIndex()) {
        long tripleEndIndex = tripleStartIndex + 2;
        if (newExtendedStart != 0) {
            tripleEndIndex = tripleEndIndex - Math.abs(newExtendedStart);
        }
        if (tripleEndIndex > cds.getEndIndex()) {
            tripleEndIndex = cds.getEndIndex();
        }
        if (!(tripleStartIndex > track.getStartIndex() && tripleEndIndex > track.getEndIndex()) &&
            !(tripleStartIndex < track.getStartIndex() && tripleEndIndex < track.getEndIndex())) {
            ProteinSequenceEntry protein = new ProteinSequenceEntry(aminoAcid, track.getId(),
                                                    cds.getStartIndex().longValue(), cds.getEndIndex().longValue(),
                                                                                tripleStartIndex, tripleEndIndex);
            protein.setIndex(aminoAcidCounter.longValue() - 1);
            proteinSequences.add(protein);
        }
    }
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:22,代码来源:ProteinSequenceReconstructionManager.java

示例6: processCds

import org.apache.commons.lang3.mutable.MutableInt; //导入依赖的package包/类
private void processCds(Track<Gene> track, final Gene cds, List<ProteinSequenceEntry> proteinSequences,
                        List<Sequence> triple, boolean isAdditionalCds, int newExtendedStart,
                        final MutableInt aminoAcidCounter) {
    if (!isAdditionalCds) {
        boolean isNegative = StrandSerializable.NEGATIVE.equals(cds.getStrand());

        // Convert nucleotide triple to amino acid.
        String aminoAcid = ProteinSequenceUtils.tripletToAminoAcid(
            triple.stream().map(Sequence::getText).collect(Collectors.joining()));

        long tripleStartIndex = isNegative? triple.get(2).getStartIndex().longValue()
                                          : triple.get(0).getStartIndex().longValue();
        if (((newExtendedStart > 0) && isNegative) || ((newExtendedStart < 0) && !isNegative)) {
            tripleStartIndex = cds.getStartIndex();
        }
        addProteinSequenceEntry(track, cds, proteinSequences, aminoAcid, tripleStartIndex, newExtendedStart,
                                aminoAcidCounter);
    }
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:20,代码来源:ProteinSequenceReconstructionManager.java

示例7: invoke

import org.apache.commons.lang3.mutable.MutableInt; //导入依赖的package包/类
public void invoke() {
  node.setNextInstruction(node.instructionPointer + 1);

  Method m = instruction.getMethod();

  try {
    m.invoke(null, subsituteArguments());

    node.executionState = isPortRead ? ExecutionState.READ : ExecutionState.RUN;

    for (Map.Entry<CommunicationPort, MutableInt> entry : writeResults.entrySet()) {
      CommunicationPort port = entry.getKey();

      port.write(entry.getValue().intValue());

      node.executionState = ExecutionState.WRITE;
    }
  } catch (Exception e) {
    logger.warn("Exception encountered during instruction execution: {}", e);
  }
}
 
开发者ID:battila7,项目名称:cd2t-100,代码行数:22,代码来源:Node.java

示例8: testWorkflowInterception_WithActualParameters

import org.apache.commons.lang3.mutable.MutableInt; //导入依赖的package包/类
@Test
public void testWorkflowInterception_WithActualParameters() throws Throwable {
    /* setup */
    final MutableInt getEventNameCall = new MutableInt(0);
    doAnswer(invocation -> {
        Event argument = (Event) invocation.getArguments()[0];
        final int currentValue = getEventNameCall.intValue();
        getEventNameCall.increment();
        return argument.name() + currentValue;
    }).when(localContext).generateEventName(any(Event.class));

    final Method invokedMethod = simpleWorkflowForTest.getClass().getDeclaredMethod("simpleDummyWorkflow", StringEvent.class, IntegerEvent.class);
    final StringEvent testStringEvent = new StringEvent("someEvent");
    final IntegerEvent testIntegerEvent = new IntegerEvent(1);
    /* invoke method */
    workflowInterceptor.invoke(dummyInvocation(invokedMethod,new Object[]{testStringEvent,testIntegerEvent}));
    /* verifications */
    verify(localContext,times(1)).addEvents(
        new EventData(SimpleWorkflowForTest.STRING_EVENT_NAME + "0", StringEvent.class.getName(), objectMapper.writeValueAsString(testStringEvent), CLIENT),
        new EventData(SimpleWorkflowForTest.INTEGER_EVENT_NAME + "1", IntegerEvent.class.getName(), objectMapper.writeValueAsString(testIntegerEvent), CLIENT)
    );
}
 
开发者ID:flipkart-incubator,项目名称:flux,代码行数:23,代码来源:WorkflowInterceptorTest.java

示例9: process

import org.apache.commons.lang3.mutable.MutableInt; //导入依赖的package包/类
@Override
public void process(T t)
{
  if (pattern.checkState(t, 0)) {
    partialMatches.add(new MutableInt(-1));
  }
  if (partialMatches.size() > 0) {
    MutableInt tempInt;
    Iterator<MutableInt> itr = partialMatches.iterator();
    while (itr.hasNext()) {
      tempInt = itr.next();
      tempInt.increment();
      if (!pattern.checkState(t, tempInt.intValue())) {
        itr.remove();
      } else if (tempInt.equals(patternLength)) {
        itr.remove();
        processPatternFound();
      }
    }
  }
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:22,代码来源:AbstractStreamPatternMatcher.java

示例10: deserializeObject

import org.apache.commons.lang3.mutable.MutableInt; //导入依赖的package包/类
@Override
public synchronized Object deserializeObject(byte[] objectBytes, MutableInt offset)
{
  int length = GPOUtils.deserializeInt(objectBytes, offset);
  int startIndex = offset.intValue();

  Map<Object, Object> primitiveMap = Maps.newHashMap();

  while (startIndex + length > offset.intValue()) {
    int typeOrdinal = GPOUtils.deserializeInt(objectBytes, offset);
    GPOType gpoType = GPOType.GPO_TYPE_ARRAY[typeOrdinal];
    Object key = gpoType.deserialize(objectBytes, offset);

    typeOrdinal = GPOUtils.deserializeInt(objectBytes, offset);
    gpoType = GPOType.GPO_TYPE_ARRAY[typeOrdinal];
    Object value = gpoType.deserialize(objectBytes, offset);
    primitiveMap.put(key, value);
  }

  return primitiveMap;
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:22,代码来源:SerdeMapPrimitive.java

示例11: deserializeObject

import org.apache.commons.lang3.mutable.MutableInt; //导入依赖的package包/类
@Override
public synchronized Object deserializeObject(byte[] object, MutableInt offset)
{
  Map<String, Type> fieldToType = Maps.newHashMap();

  int length = GPOUtils.deserializeInt(object, offset);
  int startIndex = offset.intValue();

  while (startIndex + length > offset.intValue()) {
    Type type = Type.values()[GPOUtils.deserializeInt(object, offset)];
    String value = GPOUtils.deserializeString(object, offset);

    fieldToType.put(value, type);
  }

  return new FieldsDescriptor(fieldToType);
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:18,代码来源:SerdeFieldsDescriptor.java

示例12: accept

import org.apache.commons.lang3.mutable.MutableInt; //导入依赖的package包/类
@Override
public boolean accept(RegexOccurrence occurrence) {
	if(allowedChars == null)
		return true;
	int totalChars = 0;
	int totalWords = 0;
	int nbBadWords = 0;
	MutableInt badChars = new MutableInt(0);
	for(LabelledAnnotation a:occurrence.getLabelledAnnotations()) {
		WordAnnotation w = (WordAnnotation) a.getAnnotation();
		totalChars += w.getCoveredText().length();
		totalWords += 1;
		if(isBadWord(w, badChars))
			nbBadWords +=1;
	}
	if(nbBadWords > 1)
		return false;
	if(totalChars <= totalWords*3 && totalWords > 1)
		return false;
	int badCharRate = 100*badChars.intValue()/totalChars;
	if(badCharRate >= BAD_CHAR_RATE_THRESHOLD)
		return false;
	return true;
}
 
开发者ID:termsuite,项目名称:termsuite-core,代码行数:25,代码来源:CharacterFootprintTermFilter.java

示例13: serialize

import org.apache.commons.lang3.mutable.MutableInt; //导入依赖的package包/类
/**
 * Serializes the given {@link GPOMutable} object while excluding the provided fields from the serialization.
 * @param gpo The {@link GPOMutable} to serialize.
 * @param excludedFields The fields from the {@link GPOMutable} object to exclude.
 * @return A byte array containing the serialized {@link GPOMutable}.
 */
public static byte[] serialize(GPOMutable gpo, Fields excludedFields)
{
  int slength = serializedLength(gpo);
  byte[] sbytes = new byte[slength];
  MutableInt offset = new MutableInt(0);

  Set<String> fields = gpo.getFieldDescriptor().getFields().getFields();
  Set<String> exFieldsSet = excludedFields.getFields();

  for (String field : fields) {
    if (exFieldsSet.contains(field)) {
      continue;
    }

    Type type = gpo.getFieldDescriptor().getType(field);
    GPOType gpoType = GPOType.GPO_TYPE_ARRAY[type.ordinal()];
    gpoType.serialize(gpo, field, sbytes, offset);
  }

  return sbytes;
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:28,代码来源:GPOUtils.java

示例14: deserializeLong

import org.apache.commons.lang3.mutable.MutableInt; //导入依赖的package包/类
/**
 * This method deserializes a long from the given byte array from the given offset,
 * and increments the offset appropriately.
 * @param buffer The byte buffer to deserialize from.
 * @param offset The offset to deserialize from.
 * @return The deserialized long.
 */
public static long deserializeLong(byte[] buffer, MutableInt offset)
{
  int offsetInt = offset.intValue();
  long val = ((((long)buffer[0 + offsetInt]) & 0xFFL) << 56) |
      ((((long)buffer[1 + offsetInt]) & 0xFFL) << 48) |
      ((((long)buffer[2 + offsetInt]) & 0xFFL) << 40) |
      ((((long)buffer[3 + offsetInt]) & 0xFFL) << 32) |
      ((((long)buffer[4 + offsetInt]) & 0xFFL) << 24) |
      ((((long)buffer[5 + offsetInt]) & 0xFFL) << 16) |
      ((((long)buffer[6 + offsetInt]) & 0xFFL) << 8) |
      (((long)buffer[7 + offsetInt]) & 0xFFL);

  offset.add(Type.LONG.getByteSize());
  return val;
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:23,代码来源:GPOUtils.java

示例15: deserializeDouble

import org.apache.commons.lang3.mutable.MutableInt; //导入依赖的package包/类
/**
 * This method deserializes a double from the given byte array from the given offset,
 * and increments the offset appropriately.
 * @param buffer The byte buffer to deserialize from.
 * @param offset The offset to deserialize from.
 * @return The deserialized double.
 */
public static double deserializeDouble(byte[] buffer, MutableInt offset)
{
  int offsetInt = offset.intValue();
  long val = (((long)buffer[0 + offsetInt]) & 0xFFL) << 56 |
      ((((long)buffer[1 + offsetInt]) & 0xFFL) << 48) |
      ((((long)buffer[2 + offsetInt]) & 0xFFL) << 40) |
      ((((long)buffer[3 + offsetInt]) & 0xFFL) << 32) |
      ((((long)buffer[4 + offsetInt]) & 0xFFL) << 24) |
      ((((long)buffer[5 + offsetInt]) & 0xFFL) << 16) |
      ((((long)buffer[6 + offsetInt]) & 0xFFL) << 8) |
      (((long)buffer[7 + offsetInt]) & 0xFFL);

  offset.add(Type.DOUBLE.getByteSize());
  return Double.longBitsToDouble(val);
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:23,代码来源:GPOUtils.java


注:本文中的org.apache.commons.lang3.mutable.MutableInt类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。