Example usage for com.google.common.collect Iterables getLast

List of usage examples for com.google.common.collect Iterables getLast

Introduction

In this page you can find the example usage for com.google.common.collect Iterables getLast.

Prototype

public static <T> T getLast(Iterable<T> iterable) 

Source Link

Document

Returns the last element of iterable .

Usage

From source file:io.crate.sql.tree.QualifiedNameReference.java

public QualifiedName getSuffix() {
    return QualifiedName.of(Iterables.getLast(name.getParts()));
}

From source file:service.DocumentFacade.java

public Integer createCategorie(String tableName, ArrayList<ArrayList<String>> proprieties) {
    String nom;//from   ww w  .  j a  v a  2s .c  o m
    String type;
    String defaut;
    String requette;
    requette = "CREATE TABLE " + tableName + "(\n";
    int NbrAttribut = proprieties.size() - 1;
    int comp = 0;
    for (ArrayList<String> arrayList : proprieties) {
        //for (int i = 0; i < arrayList.size(); i++) {
        comp++;
        ArrayList<String> last = Iterables.getLast(proprieties);
        nom = arrayList.get(0);
        type = arrayList.get(1);
        defaut = arrayList.get(2);
        if ((proprieties.size()) == comp) {
            requette += nom + "  " + type + " " + defaut + "\n";
        } else
            requette += nom + "  " + type + " " + defaut + ",\n";
        //}
    }
    requette += ");";
    Query query = em.createNativeQuery(requette);
    try {
        //System.out.println("---->"+requette);
        query.executeUpdate();
        FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, "",
                "Table a t ajout avec succs ");
        FacesContext.getCurrentInstance().addMessage(null, message);
        return 1;
    } catch (Exception e) {
        FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_WARN, "",
                "Une Table portant ce nom existe dj !");
        FacesContext.getCurrentInstance().addMessage(null, message);
        return 0;
    }
}

From source file:com.tangfan.test.log.Log4jMockAppender.java

/**
 * ?append?log./*  ww  w.  jav  a 2 s .  c om*/
 */
public LoggingEvent getLastLog() {
    if (logs.isEmpty()) {
        return null;
    }
    return Iterables.getLast(logs);
}

From source file:org.praat.IntervalTier.java

/**
 * Construct IntervalTier from a List of Intervals. The time domain of the IntervalTier will be determined by the start and
 * end time of the first and last Interval, respectively.
 * /* w  w w.jav a  2 s  .c  o  m*/
 * @param name
 * @param intervals
 */
public IntervalTier(String name, List<Interval> intervals) {
    this.name = name;

    // update time domain
    xmin = intervals.get(0).getStartTime();
    xmax = Iterables.getLast(intervals).getEndTime();

    items = intervals;
}

From source file:org.eclipse.xtext.xbase.typesystem.LocalVariableCapturer.java

public static void captureLocalVariables(JvmDeclaredType localType, ITypeComputationState state) {
    captureLocalVariables(Iterables.getLast(localType.getSuperTypes()), state);
}

From source file:com.threerings.presents.tools.ActionScriptUtils.java

public static String addImportAndGetShortType(Class<?> type, boolean isField, ImportSet imports) {
    String full = toActionScriptType(type, isField);
    if (needsActionScriptImport(type, isField)) {
        imports.add(full);/*from w  w  w .  j av  a  2 s.c  o m*/
    }
    return Iterables.getLast(DOT_SPLITTER.split(full));
}

From source file:com.google.javascript.jscomp.parsing.parser.util.SourcePosition.java

private String shortSourceName() {
    if (source == null) {
        return "";
    }// w w w  .  j  a va  2s  .c  o  m

    return Iterables.getLast(Splitter.on('/').split(source.name));
}

From source file:com.google.devtools.build.lib.syntax.SkylarkEnvironment.java

/**
 * Creates a Skylark Environment for function calling, from the global Environment of the
 * caller Environment (which must be a Skylark Environment).
 *//*w  ww  .  jav  a 2  s.  com*/
public static SkylarkEnvironment createEnvironmentForFunctionCalling(Environment callerEnv,
        SkylarkEnvironment definitionEnv, UserDefinedFunction function) throws EvalException {
    if (callerEnv.getStackTrace().contains(function.getName())) {
        throw new EvalException(function.getLocation(), "Recursion was detected when calling '"
                + function.getName() + "' from '" + Iterables.getLast(callerEnv.getStackTrace()) + "'");
    }
    ImmutableList<String> stackTrace = new ImmutableList.Builder<String>().addAll(callerEnv.getStackTrace())
            .add(function.getName()).build();
    SkylarkEnvironment childEnv =
            // Always use the caller Environment's EventHandler. We cannot assume that the
            // definition Environment's EventHandler is still working properly.
            new SkylarkEnvironment(definitionEnv, stackTrace, callerEnv.eventHandler);
    try {
        for (String varname : callerEnv.propagatingVariables) {
            childEnv.updateAndPropagate(varname, callerEnv.lookup(varname));
        }
    } catch (NoSuchVariableException e) {
        // This should never happen.
        throw new IllegalStateException(e);
    }
    childEnv.disabledVariables = callerEnv.disabledVariables;
    childEnv.disabledNameSpaces = callerEnv.disabledNameSpaces;
    return childEnv;
}

From source file:org.eclipse.xtend.core.typesystem.LocalClassAwareTypeNames.java

@Override
protected void doVisitParameterizedTypeReference(ParameterizedTypeReference reference, StringBuilder param) {
    JvmType type = reference.getType();/* ww w  .ja  v  a2 s.  com*/
    if (type instanceof JvmDeclaredType) {
        boolean local = ((JvmDeclaredType) type).isLocal();
        if (local) {
            param.append("new ");
            Iterables.getLast(reference.getSuperTypes()).accept(this, param);
            param.append("(){}");
            return;
        }
    }
    super.doVisitParameterizedTypeReference(reference, param);
}

From source file:io.soliton.protobuf.plugin.TypeMap.java

/**
 * @param name/*from  w w  w  .  j  a  v a 2 s  .  c om*/
 * @return
 */
@VisibleForTesting
static String createOuterJavaClassname(String name) {
    if (name.endsWith(".proto")) {
        name = name.substring(0, name.length() - ".proto".length());
    }
    name = Iterables.getLast(Splitter.on('/').split(name));
    name = name.replace('-', '_');
    name = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name);
    return Character.toUpperCase(name.charAt(0)) + name.substring(1);
}