Example usage for org.apache.commons.lang.mutable MutableBoolean booleanValue

List of usage examples for org.apache.commons.lang.mutable MutableBoolean booleanValue

Introduction

In this page you can find the example usage for org.apache.commons.lang.mutable MutableBoolean booleanValue.

Prototype

public boolean booleanValue() 

Source Link

Document

Returns the value of this MutableBoolean as a boolean.

Usage

From source file:com.darkstar.beanCartography.utils.NameUtils.java

/**
 * @param o object instanct to check/*from  w w w .  jav a 2 s.com*/
 * @return <code>true</code> if any fields have names associated with them
 */
public static boolean hasFieldBusinessNames(Object o) {
    Preconditions.checkNotNull(o, "Object cannot be null");

    // look for business field annotation...
    Map<String, List<Field>> classFieldMap = getFields(o, true);
    final MutableBoolean hasBusinessName = new MutableBoolean(false);
    classFieldMap.values().stream().forEach(fieldList -> {
        Optional<Field> fieldOpt = fieldList.stream().filter(NameUtils::hasBusinessName).findFirst();
        fieldOpt.ifPresent(field -> hasBusinessName.setValue(field != null));
    });
    return hasBusinessName.booleanValue();
}

From source file:com.palantir.ptoss.util.Reflections.java

/**
 * Checks whether or not the specified {@link Annotation} exists in the passed {@link Object}'s
 * class hierarchy./*  w  w  w. j  a v  a 2s. c om*/
 * @param object object to check
 * @param annotation annotation to look for
 * @return true is a class in this passed object's type hierarchy is annotated with the
 * passed {@link Annotation}
 */
public static boolean isClassAnnotatedForClassHierarchy(Object object,
        final Class<? extends Annotation> annotation) {
    final MutableBoolean bool = new MutableBoolean(false);
    visitClassHierarchy(object.getClass(), new Visitor<Class<?>>() {
        public void visit(Class<?> klass) {
            if (klass.isAnnotationPresent(annotation)) {
                bool.setValue(true);
            }
        }
    });
    return bool.booleanValue();
}

From source file:com.evolveum.midpoint.schema.util.ObjectQueryUtil.java

public static boolean hasAllDefinitions(ObjectFilter filter) {
    final MutableBoolean hasAllDefinitions = new MutableBoolean(true);
    Visitor visitor = new Visitor() {
        @Override/*from w w w.  j a va 2s  .  com*/
        public void visit(ObjectFilter filter) {
            if (filter instanceof ValueFilter) {
                ItemDefinition definition = ((ValueFilter<?>) filter).getDefinition();
                if (definition == null) {
                    hasAllDefinitions.setValue(false);
                }
            }
        }
    };
    filter.accept(visitor);
    return hasAllDefinitions.booleanValue();
}

From source file:com.digitalpebble.stormcrawler.protocol.okhttp.HttpProtocol.java

@Override
public ProtocolResponse getProtocolOutput(String url, Metadata metadata) throws Exception {
    Builder rb = new Request.Builder().url(url);
    rb.header("User-Agent", userAgent);

    if (metadata != null) {
        String lastModified = metadata.getFirstValue("last-modified");
        if (StringUtils.isNotBlank(lastModified)) {
            rb.header("If-Modified-Since", lastModified);
        }// w w w .  j  a v  a 2 s.com

        String ifNoneMatch = metadata.getFirstValue("etag");
        if (StringUtils.isNotBlank(ifNoneMatch)) {
            rb.header("If-None-Match", ifNoneMatch);
        }
    }

    Request request = rb.build();
    Call call = client.newCall(request);

    try (Response response = call.execute()) {

        byte[] bytes = new byte[] {};

        MutableBoolean trimmed = new MutableBoolean();
        bytes = toByteArray(response.body(), trimmed);
        if (trimmed.booleanValue()) {
            if (!call.isCanceled()) {
                call.cancel();
            }
            metadata.setValue("http.trimmed", "true");
            LOG.warn("HTTP content trimmed to {}", bytes.length);
        }

        return new ProtocolResponse(bytes, response.code(), metadata);
    }
}

From source file:com.digitalpebble.stormcrawler.protocol.httpclient.HttpProtocol.java

@Override
public ProtocolResponse handleResponse(HttpResponse response) throws ClientProtocolException, IOException {
    int status = response.getStatusLine().getStatusCode();
    Metadata metadata = new Metadata();
    HeaderIterator iter = response.headerIterator();
    while (iter.hasNext()) {
        Header header = iter.nextHeader();
        metadata.addValue(header.getName().toLowerCase(Locale.ROOT), header.getValue());
    }/*  w w w  .j  a v a  2 s .  c  om*/

    MutableBoolean trimmed = new MutableBoolean();

    byte[] bytes = HttpProtocol.toByteArray(response.getEntity(), maxContent, trimmed);

    if (trimmed.booleanValue()) {
        metadata.setValue("http.trimmed", "true");
        LOG.warn("HTTP content trimmed to {}", bytes.length);
    }

    return new ProtocolResponse(bytes, status, metadata);
}

From source file:com.hp.alm.ali.idea.entity.table.QuerySharingManager.java

public void addSharedQuery(final QuerySharing model, final String id) {
    final MutableBoolean ignore = new MutableBoolean(false);
    model.addFilterListener(new FilterListener<EntityQuery>() {
        @Override/* w w  w. j  a  va2  s .com*/
        public void filterChanged(EntityQuery query) {
            if (!ignore.booleanValue()) {
                fireChangedEvent(query, id);
            }
        }
    });
    FilterListener<EntityQuery> listener = new FilterListener<EntityQuery>() {
        @Override
        public void filterChanged(EntityQuery query) {
            LinkedHashMap<String, Integer> columns = query.getColumns();
            if (query == model.getFilter()) {
                conf.getFilter(id).setColumns(columns);
                return; // ignore our own event (only store in project configuration)
            }

            ignore.setValue(true);
            try {
                model.setColumns(columns);
            } finally {
                ignore.setValue(false);
            }
        }
    };
    addListener(id, listener);
    ref.put(model, listener); // make sure the listener is not garbage collected
}

From source file:net.itransformers.expect4java.Expect4JavaTest.java

@Test
public void testGlob() throws IOException, MalformedPatternException {
    final MutableBoolean status = new MutableBoolean(false);
    e4j.send("hello\n");
    e4j.expect(new GlobMatch("hello\n", it -> {
        System.out.println("Hello World!");
        status.setValue(true);//from   ww  w. j av a  2s  .c o  m
    }));
    Assert.assertTrue(status.booleanValue());
}

From source file:net.itransformers.expect4java.Expect4JavaTest.java

@Test
public void testRegex() throws IOException, MalformedPatternException {
    final MutableBoolean status = new MutableBoolean(false);
    e4j.send("hello World\n");
    e4j.expect(new RegExpMatch("hello ([^\n]*)\n", (ExpectContext context) -> {
        System.out.println("Hello " + context.getMatch(1));
        status.setValue(true);/*from  w  w  w . j  a  v a2s .co m*/
    }));
    Assert.assertTrue(status.booleanValue());
}

From source file:com.metamx.druid.realtime.plumber.RealtimePlumberSchoolTest.java

@Test
public void testPersist() throws Exception {
    final MutableBoolean committed = new MutableBoolean(false);
    plumber.startJob();//w w  w.  j  a  v a2  s.  c om
    plumber.persist(new Runnable() {
        @Override
        public void run() {
            committed.setValue(true);
        }
    });

    Stopwatch stopwatch = new Stopwatch().start();
    while (!committed.booleanValue()) {
        Thread.sleep(100);
        if (stopwatch.elapsed(TimeUnit.MILLISECONDS) > 1000) {
            throw new ISE("Taking too long to set perist value");
        }
    }
    plumber.finishJob();
}

From source file:mitm.common.util.SizeLimitedOutputStreamTest.java

@Test
public void testClose() throws IOException {
    final MutableBoolean closeCalled = new MutableBoolean();

    ByteArrayOutputStream bos = new ByteArrayOutputStream() {
        @Override// w  ww .  j  ava  2  s.  com
        public void close() {
            closeCalled.setValue(true);
        }
    };

    SizeLimitedOutputStream slo = new SizeLimitedOutputStream(bos, 100);

    assertFalse(closeCalled.booleanValue());

    slo.close();

    assertTrue(closeCalled.booleanValue());
}