List of usage examples for java.util Collections unmodifiableList
public static <T> List<T> unmodifiableList(List<? extends T> list)
From source file:MainClass.java
public List getFoods() { return Collections.unmodifiableList(foods); }
From source file:com.cloudyle.paasplus.petclinic.persistence.entities.nosql.Owner.java
public List<Pet> getPets() { List<Pet> sortedPets = new ArrayList<Pet>(getPetsInternal()); return Collections.unmodifiableList(sortedPets); }
From source file:org.shaigor.rest.retro.service.impl.WordServiceImpl.java
/** * Reads the content of the file on start-up using the path property 'path' * and the charset 'charset' property provided * through resource injection/* w w w.ja v a 2 s.c o m*/ */ @PostConstruct public void init() { log.info("The dictionary file {} is in {} charset", charset, path); BufferedReader br = null; List<String> fileContent = new ArrayList<String>(); try { br = new BufferedReader(new InputStreamReader(new FileInputStream(path), charset)); String strLine; while ((strLine = br.readLine()) != null) { fileContent.add(strLine); } } catch (Exception e) { log.error("Could not read from file", e); } finally { if (br != null) { try { br.close(); } catch (IOException e) { log.error("Could not close the file", e); } } } words = Collections.unmodifiableList(fileContent); log.info("The dictionary file {} loaded with {} entries", path, words.size()); }
From source file:net.dv8tion.jda.core.entities.impl.MemberImpl.java
@Override public List<Permission> getPermissions(Channel channel) { if (!guild.equals(channel.getGuild())) throw new IllegalArgumentException("Provided channel is not in the same guild as this member!"); return Collections .unmodifiableList(Permission.getPermissions(PermissionUtil.getEffectivePermission(channel, this))); }
From source file:com.vmware.identity.openidconnect.protocol.JWTToken.java
protected JWTToken(TokenClass tokenClass, SignedJWT signedJwt) throws ParseException { Validate.notNull(tokenClass, "tokenClass"); Validate.notNull(signedJwt, "signedJwt"); this.tokenClass = tokenClass; JWTClaimsSet claims = JWTUtils.getClaimsSet(signedJwt); String tokenClassStringClaim = JWTUtils.getString(claims, this.tokenClass, "token_class"); TokenClass tokenClassClaim;//ww w .ja va 2 s . co m try { tokenClassClaim = TokenClass.parse(tokenClassStringClaim); } catch (ParseException e) { throw new ParseException(this.tokenClass.getValue() + " has invalid token_class claim", e); } if (tokenClassClaim != this.tokenClass) { throw new ParseException(this.tokenClass.getValue() + " has incorrect token_class claim"); } String tokenTypeString = JWTUtils.getString(claims, this.tokenClass, "token_type"); try { this.tokenType = TokenType.parse(tokenTypeString); } catch (ParseException e) { throw new ParseException(this.tokenClass.getValue() + " has invalid token_type claim", e); } this.jwtId = new JWTID(JWTUtils.getString(claims, this.tokenClass, "jti")); this.issuer = new Issuer(JWTUtils.getString(claims, this.tokenClass, "iss")); this.subject = new Subject(JWTUtils.getString(claims, this.tokenClass, "sub")); this.audience = Collections .unmodifiableList(Arrays.asList(JWTUtils.getStringArray(claims, this.tokenClass, "aud"))); this.issueTime = JWTUtils.getIssueTime(claims, this.tokenClass); if (this.audience.isEmpty()) { throw new ParseException(this.tokenClass.getValue() + " aud must be non-empty"); } }
From source file:de.mirkosertic.desktopsearch.QueryTokenizer.java
public List<String> getNotRequiredTerms() { return Collections.unmodifiableList(notRequiredTerms); }
From source file:com.ksc.http.IdleConnectionReaper.java
@SdkTestInternalApi public static synchronized List<HttpClientConnectionManager> getRegisteredConnectionManagers() { return Collections.unmodifiableList(connectionManagers); }
From source file:com.anrisoftware.prefdialog.miscswing.editcontextmenu.EditContextMenu.java
@Inject void setOpenContextMenu(OpenContextMenu menu) { List<ContextMenuAction> actions = new ArrayList<ContextMenuAction>(); actions.add(copyAction);//from w w w.j a v a 2 s .c o m actions.add(cutAction); actions.add(pasteAction); actions.add(selectAllAction); actions.add(deleteAction); this.actionsList = Collections.unmodifiableList(actions); menu.setActions(actionsList); this.openContextMenu = menu; }
From source file:com.sysunite.weaver.nifi.GetXMLNodes.java
@Override protected void init(final ProcessorInitializationContext context) { final List<PropertyDescriptor> descriptors = new ArrayList<PropertyDescriptor>(); descriptors.add(PROP_XPATH);/*from www.j ava 2 s . co m*/ this.descriptors = Collections.unmodifiableList(descriptors); final Set<Relationship> relationships = new HashSet<Relationship>(); relationships.add(MY_RELATIONSHIP); this.relationships = Collections.unmodifiableSet(relationships); }
From source file:com.clustercontrol.selfcheck.monitor.TableSizeMonitor.java
/** * ???/* w ww .ja va2 s. c o m*/ */ @Override public void execute() { if (!HinemosPropertyUtil.getHinemosPropertyBool("selfcheck.monitoring.table.size", true)) { m_log.debug("skip"); return; } String tableSizeRaw = HinemosPropertyUtil.getHinemosPropertyStr("selfcheck.monitoring.table.size.list", "log.cc_event_log:20480:MBYTE,log.cc_collect_data_raw:20480:MBYTE,log.cc_collect_data_string:40960:MBYTE,log.cc_job_session:100000:COUNT"); List<TableSizeConfig> tableSizes = new ArrayList<TableSizeConfig>(); for (String tableSize : tableSizeRaw.split(",")) { String[] pair = tableSize.split(":"); if (pair.length == 3) { ThresholdType type; try { type = ThresholdType.valueOf(pair[2]); } catch (IllegalArgumentException e) { m_log.warn("table size monitoring - invalid type, set [MBYTE|COUNT]. : " + tableSize); continue; } tableSizes.add(new TableSizeConfig(pair[0], type, Long.parseLong(pair[1]))); } } List<TableSizeConfig> tableList = Collections.unmodifiableList(tableSizes); for (TableSizeConfig config : tableList) { String tableName = config.tableName; long threshold = config.threshold; ThresholdType thresholdType = config.thresdholdType; String subKey = tableName; /** */ JpaTransactionManager tm = null; long size = -1; long thresholdOrig = threshold; long physicalSize = -1; double physicalSizeMByte = -1.0; long count = -1; long sizeThresdhold = threshold; boolean warn = true; /** ? */ m_log.debug("monitoring table size. (tableName=" + tableName + ", threshold=" + threshold + " [" + getThresholdUnit(thresholdType) + "])"); try { // ?JNDI???????????????? tm = new JpaTransactionManager(); tm.begin(); // ?? switch (thresholdType) { case MBYTE: // convert MByte to byte sizeThresdhold = threshold * 1024 * 1024; size = getTableSize(tableName); break; case COUNT: sizeThresdhold = threshold; size = getTableCount(tableName); break; default: m_log.info("monitoring type is invalid. (type = " + thresholdType + ")"); } if (size == -1) { if (m_log.isInfoEnabled()) { m_log.info("skipped monitoring table. (tableName=" + tableName + ", threshold=" + thresholdOrig + " [" + getThresholdUnit(thresholdType) + "])"); } } else if (size <= sizeThresdhold) { if (m_log.isDebugEnabled()) { m_log.debug("table's size is low. (tableName=" + tableName + ", size=" + size + ", threshold=" + thresholdOrig + " [" + getThresholdUnit(thresholdType) + "])"); } warn = false; } } catch (Exception e) { if (tm != null) tm.rollback(); m_log.warn("monitoring log table failure. (tableName=" + tableName + ", threshold=" + threshold + " [" + getThresholdUnit(thresholdType) + "])", e); } finally { if (tm != null) { tm.close(); } } if (warn) { m_log.info("log table's size is too high. (tableName=" + tableName + ", size=" + size + ", threshold=" + thresholdOrig + " " + getThresholdUnit(thresholdType) + ")"); } if (!isNotify(subKey, warn)) { return; } switch (thresholdType) { case MBYTE: physicalSize = size; count = getTableCount(tableName); break; case COUNT: physicalSize = getTableSize(tableName); count = size; break; default: m_log.info("monitoring type is invalid. (type=" + thresholdType + ")"); } physicalSizeMByte = physicalSize / 1024.0 / 1024.0; String[] msgAttr1 = { tableName, String.format("%.2f", physicalSizeMByte), Long.toString(count), Long.toString(thresholdOrig), getThresholdUnit(thresholdType) }; AplLogger.put(PriorityConstant.TYPE_WARNING, PLUGIN_ID, MessageConstant.MESSAGE_SYS_006_SYS_SFC, msgAttr1, "stored data (" + tableName + ") is too large (" + String.format("%.2f", physicalSizeMByte) + " [mbyte], " + count + " [rows(statistics)] > threshold " + thresholdOrig + " " + getThresholdUnit(thresholdType) + ")."); } return; }