List of usage examples for java.util Collections unmodifiableList
public static <T> List<T> unmodifiableList(List<? extends T> list)
From source file:com.activecq.api.ActiveProperties.java
/** * Uses reflection to create a List of the keys defined in the ActiveField subclass (and its inheritance tree). * Only fields that meet the following criteria are returned: * - public/* w w w. java2s . com*/ * - static * - final * - String * - Upper case * @return a List of all the Fields */ @SuppressWarnings("unchecked") public List<String> getKeys() { ArrayList<String> keys = new ArrayList<String>(); ArrayList<String> names = new ArrayList<String>(); Class cls = this.getClass(); if (cls == null) { return Collections.unmodifiableList(keys); } Field fieldList[] = cls.getFields(); for (Field fld : fieldList) { int mod = fld.getModifiers(); // Only look at public static final fields if (!Modifier.isPublic(mod) || !Modifier.isStatic(mod) || !Modifier.isFinal(mod)) { continue; } // Only look at String fields if (!String.class.equals(fld.getType())) { continue; } // Only look at uppercase fields if (!StringUtils.equals(fld.getName().toUpperCase(), fld.getName())) { continue; } // Get the value of the field String value; try { value = StringUtils.stripToNull((String) fld.get(this)); } catch (IllegalArgumentException e) { continue; } catch (IllegalAccessException e) { continue; } // Do not add duplicate or null keys, or previously added named fields if (value == null || names.contains(fld.getName()) || keys.contains(value)) { continue; } // Success! Add key to key list keys.add(value); // Add field named to process field names list names.add(fld.getName()); } return Collections.unmodifiableList(keys); }
From source file:io.github.carlomicieli.footballdb.starter.pages.Table.java
protected Table(TableBuilder tb) { this.size = ImmutablePair.of(tb.size.getKey(), tb.size.getValue()); this.headers = Collections.unmodifiableList(tb.columnHeaders); this.rows = tb.values.stream().map(r -> Row.of(r, headers)).collect(Collectors.toList()); }
From source file:de.dhke.projects.cutil.collections.frozen.FrozenSortedList.java
public FrozenSortedList(final Collection<? extends T> source) { final SortedListSet<T> elements = new SortedListSet<>(source); _elements = Collections.unmodifiableList(elements); }
From source file:com.github.zdsiyan.maven.plugin.smartconfig.model.ConfigFile.java
public List<PointHandle> getPointHandles() { return Collections.unmodifiableList(pointHandles); }
From source file:Main.java
/** * Parses the contents of {@link Engine#EXTRA_AVAILABLE_VOICES} and returns * a unmodifiable list of {@link Locale}s sorted by display name. See * {@link #LOCALE_COMPARATOR} for sorting information. * * @param availableLanguages A list of locale strings in the form * {@code language-country-variant}. * @return A sorted, unmodifiable list of {@link Locale}s. *//* w w w. j a v a2 s . com*/ public static List<Locale> parseAvailableLanguages(List<String> availableLanguages) { final List<Locale> results = new ArrayList<Locale>(availableLanguages.size()); for (String availableLang : availableLanguages) { final String[] langCountryVar = availableLang.split("-"); final Locale loc; if (langCountryVar.length == 1) { loc = new Locale(langCountryVar[0]); } else if (langCountryVar.length == 2) { loc = new Locale(langCountryVar[0], langCountryVar[1]); } else if (langCountryVar.length == 3) { loc = new Locale(langCountryVar[0], langCountryVar[1], langCountryVar[2]); } else { continue; } results.add(loc); } // Sort by display name, ascending case-insensitive. Collections.sort(results, LOCALE_COMPARATOR); return Collections.unmodifiableList(results); }
From source file:com.liferay.mobile.sdk.http.Discovery.java
public List<Action> getActions() { return Collections.unmodifiableList(_actions); }
From source file:com.zb.app.web.tools.EnumViewTools.java
public static List<LineDayEnum> getAllLineDay() { if (lineDayEnumList == null) { lineDayEnumList = new ArrayList<LineDayEnum>(); for (LineDayEnum _enum : LineDayEnum.values()) { lineDayEnumList.add(_enum); }//from www. j ava 2s . com lineDayEnumList = Collections.unmodifiableList(lineDayEnumList); } return lineDayEnumList; }
From source file:com.buffalokiwi.aerodrome.jet.JetException.java
/** * Constructs an instance of <code>JetException</code> with the specified * detail message.//from w ww. ja v a 2s . c o m * * @param msg the detail message. */ public JetException(String msg) { super(msg); response = null; messages = Collections.unmodifiableList(new ArrayList<String>()); }
From source file:com.frank.search.solr.core.query.AbstractFunction.java
@SuppressWarnings("unchecked") @Override public List<?> getArguments() { return Collections.unmodifiableList(this.arguments); }
From source file:de.xirp.db.ChartDatabaseUtil.java
/** * Returns all {@link de.xirp.db.Observed} for the * given record and key name./*from ww w . j av a2s .co m*/ * * @param record * The record to look in. * @param keyname * The name of the observed key. * @return A list with all <code>Observed</code> for the record * and key. * @see de.xirp.db.Observed */ @SuppressWarnings("unchecked") public static List<Observed> getObservedList(Record record, String keyname) { Session session = DatabaseManager.getCurrentHibernateSession(); session.getTransaction().begin(); Query query = session.createQuery("FROM Observed as obs WHERE obs.record = ? and obs.observedKey = ?"); //$NON-NLS-1$ query.setEntity(0, record); query.setString(1, keyname); List<Observed> obs = query.list(); session.close(); return Collections.unmodifiableList(obs); }