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


Java MutableObject.setValue方法代码示例

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


在下文中一共展示了MutableObject.setValue方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: shouldAllowSameMethodRegistrationFromDifferentThreads

import org.apache.commons.lang3.mutable.MutableObject; //导入方法依赖的package包/类
@Test
public void shouldAllowSameMethodRegistrationFromDifferentThreads() throws Exception {

    final MutableObject<StateMachineDefinition> definitionOne = new MutableObject<>(null);
    final MutableObject<StateMachineDefinition> definitionTwo = new MutableObject<>(null);

    final Thread thread1 = new Thread(() -> {
        localContext.registerNew("fooBar", 1, "someDescription","someContext");
        definitionOne.setValue(tlStateMachineDef.get());
    });
    final Thread thread2 = new Thread(() -> {
        localContext.registerNew("fooBar", 1, "someDescription","someContext");
        definitionTwo.setValue(tlStateMachineDef.get());
    });
    thread1.start();
    thread2.start();

    thread1.join();
    thread2.join();

    assertThat(definitionOne.getValue()).isNotNull().isEqualTo(definitionTwo.getValue()).isEqualTo(new StateMachineDefinition("someDescription", "fooBar", 1l, new HashSet<>(), new HashSet<>(), "someContext"));
}
 
开发者ID:flipkart-incubator,项目名称:flux,代码行数:23,代码来源:LocalContextTest.java

示例2: blockingSynchronize

import org.apache.commons.lang3.mutable.MutableObject; //导入方法依赖的package包/类
/**
 * Request a remote synchronization. This call blocks until the operation is complete,
 * or the thread is interrupted.
 * 
 * @throws InterruptedException
 */
public SynchronizeResult blockingSynchronize() throws InterruptedException
{
	log.info("Queuing a blocking sync request");
	final MutableObject<SynchronizeResult> result = new MutableObject<SynchronizeResult>();
	final CountDownLatch cdl = new CountDownLatch(1);
	Consumer<SynchronizeResult> callback = new Consumer<SynchronizeResult>()
	{
		@Override
		public void accept(SynchronizeResult t)
		{
			result.setValue(t);
			cdl.countDown();
		}
	};

	synchronize(callback);
	cdl.await();
	return result.getValue();
}
 
开发者ID:Apelon-VA,项目名称:ISAAC,代码行数:26,代码来源:RemoteSynchronizer.java

示例3: createServer

import org.apache.commons.lang3.mutable.MutableObject; //导入方法依赖的package包/类
private Callable<Object> createServer(final MutableObject<String> actualRequest) {
    return new Callable<Object>() {
        @Override
        public Object call() throws Exception {
            LOGGER.info("SERVER: receiving request");
            UDPTransport transport = new UDPTransport(SERVER_PORT);
            String request = transport.receive();
            actualRequest.setValue(request);

            LOGGER.info("SERVER: sending answer");
            transport.send(ANSWER);

            LOGGER.info("SERVER: finished");
            return null;
        }
    };
}
 
开发者ID:fduminy,项目名称:jtestplatform,代码行数:18,代码来源:UDPClientServerTest.java

示例4: createClient

import org.apache.commons.lang3.mutable.MutableObject; //导入方法依赖的package包/类
private Callable<Object> createClient(final MutableObject<String> actualAnswer) {
    return new Callable<Object>() {
        @Override
        public Object call() throws Exception {
            LOGGER.info("CLIENT: sending request");
            UDPTransport transport = new UDPTransport(InetAddress.getLocalHost(), SERVER_PORT, TIMEOUT);
            transport.send(REQUEST);

            LOGGER.info("CLIENT: receiving answer");
            String answer = transport.receive();
            actualAnswer.setValue(answer);

            LOGGER.info("CLIENT: finished");
            return null;
        }
    };
}
 
开发者ID:fduminy,项目名称:jtestplatform,代码行数:18,代码来源:UDPClientServerTest.java

示例5: evaluate

import org.apache.commons.lang3.mutable.MutableObject; //导入方法依赖的package包/类
private void evaluate(WebDriver driver, WebElementSelector locator, BiFunction<WebDriver, WebElementSelector, String> callback, boolean disableValueCheck, MutableObject<String> resultHolder) {
	String result = StringUtils.stripToEmpty(callback.apply(driver, locator));
	resultHolder.setValue(result);
	String expectedValue = locator.getExpectedValue();
	if (disableValueCheck || StringUtils.isBlank(expectedValue) || this.fitnesseMarkup.compare(expectedValue, result)) {
		return;
	}
	throw new NoSuchElementException(MessageFormat.format("Element with unexpected value [Expected: {0}, Obtained: {1}]", expectedValue, result));
}
 
开发者ID:andreptb,项目名称:fitnesse-selenium-slim,代码行数:10,代码来源:WebDriverHelper.java

示例6: getString

import org.apache.commons.lang3.mutable.MutableObject; //导入方法依赖的package包/类
private String getString(String name)
{
	int functionId = this.getNewId();
	this.sendString(String.format("GET %s %i\r\n\r\n", name, functionId));
	String pattern = String.format("RESP %i (.*)\r\n\r\n", functionId);
	MutableObject<String> result = new MutableObject<>(null);
	Consumer<String> callback = (input) ->
	{
		result.setValue(Pattern.compile(pattern).matcher(input).group(1));
	};
	this.awaitMessage("", callback);
	while(result.getValue() == null)
		this.getNextMessage();
	return result.getValue();
}
 
开发者ID:slaymaker1907,项目名称:triple-triad-ai,代码行数:16,代码来源:ClientController.java

示例7: deserialize

import org.apache.commons.lang3.mutable.MutableObject; //导入方法依赖的package包/类
@Override
@SuppressWarnings( "unchecked" )
public MutableObject deserialize( JsonParser p,
                                  DeserializationContext ctxt ) throws IOException {

    try {
        final MutableObject vc = ( MutableObject ) _valueClass.newInstance();

        vc.setValue( ctxt.readValue( p, refType ) );

        return vc;
    } catch( InstantiationException | IllegalAccessException e ) {
        throw ctxt.instantiationException( _valueClass, e );
    }
}
 
开发者ID:oaplatform,项目名称:oap,代码行数:16,代码来源:MutableObjectModule.java

示例8: parseParameter

import org.apache.commons.lang3.mutable.MutableObject; //导入方法依赖的package包/类
private void parseParameter(String parameter,
		MutableObject<String> whereClause,
		MutableObject<String[]> whereParameter) {
	// get whereClause and whereParameter
	Pattern p = Pattern.compile("^\\[([^,]+),([^,]+)\\]$");
	Matcher m = p.matcher(parameter);
	if (m.find()) {
		whereClause.setValue("between ? and ?");
		whereParameter.setValue(new String[] { m.group(1), m.group(2) });
		return;
	}

	whereClause.setValue("=?");
	whereParameter.setValue(new String[] { parameter });
}
 
开发者ID:dangpin,项目名称:aureum,代码行数:16,代码来源:OracleModelReader.java

示例9: hierarchy

import org.apache.commons.lang3.mutable.MutableObject; //导入方法依赖的package包/类
public static Iterable<Class<?>> hierarchy(final Class<?> type, final Interfaces interfacesBehavior) {
    final Iterable<Class<?>> classes = new Iterable<Class<?>>() {

        @Override
        public Iterator<Class<?>> iterator() {
            final MutableObject<Class<?>> next = new MutableObject<Class<?>>(type);
            return new Iterator<Class<?>>() {

                @Override
                public boolean hasNext() {
                    return next.getValue() != null;
                }

                @Override
                public Class<?> next() {
                    final Class<?> result = next.getValue();
                    next.setValue(result.getSuperclass());
                    return result;
                }

                @Override
                public void remove() {
                    throw new UnsupportedOperationException();
                }

            };
        }

    };
    if (interfacesBehavior != Interfaces.INCLUDE) {
        return classes;
    }
    return new Iterable<Class<?>>() {

        @Override
        public Iterator<Class<?>> iterator() {
            final Set<Class<?>> seenInterfaces = new HashSet<Class<?>>();
            final Iterator<Class<?>> wrapped = classes.iterator();

            return new Iterator<Class<?>>() {
                Iterator<Class<?>> interfaces = Collections.<Class<?>> emptySet().iterator();

                @Override
                public boolean hasNext() {
                    return interfaces.hasNext() || wrapped.hasNext();
                }

                @Override
                public Class<?> next() {
                    if (interfaces.hasNext()) {
                        final Class<?> nextInterface = interfaces.next();
                        seenInterfaces.add(nextInterface);
                        return nextInterface;
                    }
                    final Class<?> nextSuperclass = wrapped.next();
                    final Set<Class<?>> currentInterfaces = new LinkedHashSet<Class<?>>();
                    walkInterfaces(currentInterfaces, nextSuperclass);
                    interfaces = currentInterfaces.iterator();
                    return nextSuperclass;
                }

                private void walkInterfaces(final Set<Class<?>> addTo, final Class<?> c) {
                    for (final Class<?> iface : c.getInterfaces()) {
                        if (!seenInterfaces.contains(iface)) {
                            addTo.add(iface);
                        }
                        walkInterfaces(addTo, iface);
                    }
                }

                @Override
                public void remove() {
                    throw new UnsupportedOperationException();
                }

            };
        }
    };
}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:80,代码来源:ClassHierarchyIncludingInterfaces.java

示例10: testReceive_ErrorMessage

import org.apache.commons.lang3.mutable.MutableObject; //导入方法依赖的package包/类
@Test
public void testReceive_ErrorMessage() throws Exception {
    // prepare
    final String expectedErrorMessage = "errorMessage";
    thrown.expect(TransportException.class);
    thrown.expect(new BaseMatcher<Throwable>() {
        private final String exceptionMessage = "Received Error : " + expectedErrorMessage;

        @Override
        public void describeTo(Description description) {
            description.appendText("a TransportException with ErrorMessage(" + exceptionMessage + ")");
        }

        @Override
        public boolean matches(Object item) {
            if (!(item instanceof TransportException)) {
                return false;
            }

            TransportException exception = (TransportException) item;
            if (!equalTo(exceptionMessage).matches(exception.getMessage())) {
                return false;
            }
            ErrorMessage errorMessage = exception.getErrorMessage();
            return (errorMessage != null) && equalTo(expectedErrorMessage).matches(errorMessage.getMessage());
        }
    });

    final MutableObject<Message> messageWrapper = new MutableObject<Message>();
    Transport transport = mock(Transport.class);
    when(transport.receive()).thenReturn(ErrorMessage.class.getName(), expectedErrorMessage);
    TransportHelper helper = new TransportHelper() {
        @Override
        Message createMessage(Class<? extends Message> clazz)
            throws InstantiationException, IllegalAccessException {
            Message message = spy(super.createMessage(clazz));
            messageWrapper.setValue(message);
            return message;
        }
    };

    // test
    helper.receive(transport);
}
 
开发者ID:fduminy,项目名称:jtestplatform,代码行数:45,代码来源:TransportHelperTest.java


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