Example usage for java.util NoSuchElementException NoSuchElementException

List of usage examples for java.util NoSuchElementException NoSuchElementException

Introduction

In this page you can find the example usage for java.util NoSuchElementException NoSuchElementException.

Prototype

public NoSuchElementException(String s) 

Source Link

Document

Constructs a NoSuchElementException , saving a reference to the error message string s for later retrieval by the getMessage method.

Usage

From source file:de.codesourcery.spring.contextrewrite.AnnotationParser.java

/**
 * Parse rewrite annotations.// w w w. j av a 2  s . c  o  m
 * 
 * @param clazz class whose annotations should be parsed. This method will also parse parent classes and merge any rewriting annotations it encounters 
 *             according to the rules described in {@link RewriteConfig#getRules()}.
 *               
 * @return rewriting configuration
 * @throws NoSuchElementException if neither the input class nor any of its parents had a {@link ContextConfiguration} annotation.
 */
public RewriteConfig parse(Class<?> clazz) throws NoSuchElementException {
    Validate.notNull(clazz, "clazz must not be NULL");

    RewriteConfig first = null;
    RewriteConfig previous = null;
    Class<?> currentClass = clazz;
    while (currentClass != Object.class) {
        final Optional<ContextConfiguration> ctxConfiguration = Optional
                .ofNullable(currentClass.getAnnotation(ContextConfiguration.class));

        final RewriteConfig config = new RewriteConfig(currentClass);

        if (ctxConfiguration.isPresent()) {
            config.setContextPath(ctxConfiguration.get().value());
            config.setDebug(ctxConfiguration.get().debug());
            config.setDumpXML(ctxConfiguration.get().dumpRewrittenXML());
        }

        config.addRules(XMLRewrite.wrap(currentClass.getAnnotationsByType(ReplaceRule.class)));
        config.addRules(XMLRewrite.wrap(currentClass.getAnnotationsByType(RemoveRule.class)));
        config.addRules(XMLRewrite.wrap(currentClass.getAnnotationsByType(InsertElementRule.class)));
        config.addRules(XMLRewrite.wrap(currentClass.getAnnotationsByType(InsertAttributeRule.class)));

        if (ctxConfiguration.isPresent() || config.hasRules()) {
            if (previous != null) {
                previous.setParent(config);
            }
            previous = config;

            if (first == null) {
                first = config;
            }
        }
        currentClass = currentClass.getSuperclass();
    }
    if (first == null) {
        throw new NoSuchElementException("Found no @" + ContextConfiguration.class.getName() + " annotation on "
                + clazz.getName() + " or any of its super classes");
    }
    return first;
}

From source file:org.trustedanalytics.servicebroker.h2o.config.ZookeeperConfig.java

private String getPropertyFromCredentials(PropertyLocator property) throws IOException {
    return confHelper.getPropertyFromEnv(property)
            .orElseThrow(() -> new NoSuchElementException(property.name() + " not found in VCAP_SERVICES"));
}

From source file:io.knotx.knot.action.domain.FormEntity.java

private static String getAdapterName(Fragment fragment, Document scriptDocument) {
    return Optional.ofNullable(scriptDocument.getElementsByAttribute(FORM_ACTION_ATTR).first())
            .map(element -> element.attr(FORM_ACTION_ATTR)).orElseThrow(() -> {
                LOGGER.error("Could not find action adapter name in fragment [{}].", fragment);
                return new NoSuchElementException("Could not find action adapter name");
            });//w ww. ja v a2  s . c o m
}

From source file:de.tbuchloh.kiskis.util.Settings.java

/**
 * @return the fully qualified classname.
 *//*w ww  .j av  a2 s  .c o  m*/
public static String getCryptoEngineClass() {
    final String ret = PREF.get(K_CRYPTO_ENGINE_CLASS, D_CRYPTO_ENGINE_CLASS);
    if (ret == null) {
        throw new NoSuchElementException(K_CRYPTO_ENGINE_CLASS);
    }
    return ret;
}

From source file:com.isencia.passerelle.actor.gui.BasePasserelleQuery.java

public String getStringValue(String name) throws NoSuchElementException, IllegalArgumentException {
    try {//from   w  w w . ja  va  2s. c o  m
        return BeanUtils.getProperty(passerelleComponent, name).toString();
    } catch (Exception e) {
        logger.error("error retrieving property " + name + " from " + passerelleComponent, e);
        throw new NoSuchElementException(e.getMessage());
    }
}

From source file:org.esbtools.eventhandler.lightblue.DocumentEventEntity.java

@Transient
@Nullable/*from  w  w  w.jav  a  2 s. c  o m*/
public String getParameterByKey(String key) {
    for (KeyAndValue keyAndValue : parameters) {
        if (Objects.equals(key, keyAndValue.getKey())) {
            return keyAndValue.getValue();
        }
    }
    throw new NoSuchElementException(key);
}

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

@Override
public Entry next() {
    if (!hasNext()) {
        throw new NoSuchElementException("No more entries");
    } else {//  www.  j  a v a2  s . c  o  m
        Entry entry = cachedEntry;

        cachedEntry = null;

        return entry;
    }
}

From source file:de.unioninvestment.eai.portal.portlet.crud.domain.portal.Portal.java

/**
 * Ermittelt die UserId eines Benutzers.
 * /*from w  ww  . jav  a  2  s. com*/
 * @param username
 *            Benutzername
 * @return UserId
 */
User getUser(String username) {
    try {
        User user = UserLocalServiceUtil.getUserByScreenName(getCompanyId(), username);
        if (user == null) {
            throw new NoSuchElementException("No Liferay userId found for username '" + username + "'");
        }
        return user;

    } catch (SystemException e) {
        throw new TechnicalCrudPortletException("Error getting user for username ' " + username + "'", e);
    } catch (PortalException e) {
        throw new TechnicalCrudPortletException("Error getting user for username ' " + username + "'", e);
    }

}

From source file:LineIterator.java

/**
 * Returns the next line in the wrapped <code>Reader</code>.
 *
 * @return the next line from the input/*from   w w w. j ava2s  . com*/
 * @throws NoSuchElementException if there is no line to return
 */
public String nextLine() {
    if (!hasNext()) {
        throw new NoSuchElementException("No more lines");
    }
    String currentLine = cachedLine;
    cachedLine = null;
    return currentLine;
}

From source file:natalia.dymnikova.cluster.scheduler.impl.SetFlowFactory.java

private Stage makeStages(final List<StageContainer> resolvedStages, final List<Optional<Address>> addresses,
        final int i) {
    final StageContainer stageContainer = resolvedStages.get(i);
    final Optional<Address> currAddress = addresses.get(i);
    final List<Stage> children = stageContainer.previous.stream()
            .map(stage -> makeStages(resolvedStages, addresses, stage.id)).collect(toList());
    return currAddress.map(address -> {
        if (stageContainer.stageType == Merge) {
            return flowMerger.createMergeStages(children, stageContainer,
                    previousStageContainerAddress(resolvedStages, stageContainer, addresses));
        }//  w  w w  .j a v a 2 s. c om

        return Stage.newBuilder().setOperator(stageContainer.remoteBytes)
                .setAddress(currAddress.get().toString()).setType(stageContainer.stageType)
                .setId(stageContainer.id).addAllStages(children).build();

    }).orElseThrow(() -> new NoSuchElementException("No candidate for stage " + stageContainer.action));
}