List of usage examples for java.lang Boolean equals
public boolean equals(Object obj)
From source file:org.apache.pig.impl.logicalLayer.optimizer.OpLimitOptimizer.java
@Override public boolean check(List<LogicalOperator> nodes) throws OptimizerException { if ((nodes == null) || (nodes.size() <= 0)) { int errCode = 2052; String msg = "Internal error. Cannot retrieve operator from null or empty list."; throw new OptimizerException(msg, errCode, PigException.BUG); }// w w w. ja va2 s . co m try { LogicalOperator lo = nodes.get(0); if (lo == null || !(lo instanceof LOLimit)) { int errCode = 2005; String msg = "Expected " + LOLimit.class.getSimpleName() + ", got " + (lo == null ? lo : lo.getClass().getSimpleName()); throw new OptimizerException(msg, errCode, PigException.BUG); } List<LogicalOperator> predecessors = mPlan.getPredecessors(lo); if (predecessors.size() != 1) { int errCode = 2008; String msg = "Limit cannot have more than one input. Found " + predecessors.size() + " inputs."; throw new OptimizerException(msg, errCode, PigException.BUG); } LogicalOperator predecessor = predecessors.get(0); // Limit cannot be pushed up if (predecessor instanceof LOCogroup || predecessor instanceof LOFilter || predecessor instanceof LOLoad || predecessor instanceof LOSplit || predecessor instanceof LODistinct || predecessor instanceof LOJoin) { return false; } // Limit cannot be pushed in front of ForEach if it has a flatten if (predecessor instanceof LOForEach) { LOForEach loForEach = (LOForEach) predecessor; List<Boolean> mFlatten = loForEach.getFlatten(); boolean hasFlatten = false; for (Boolean b : mFlatten) if (b.equals(true)) hasFlatten = true; if (hasFlatten) { return false; } } } catch (Exception e) { int errCode = 2049; String msg = "Error while performing checks to optimize limit operator."; throw new OptimizerException(msg, errCode, PigException.BUG); } return true; }
From source file:de.awisus.refugeeaidleipzig.MainActivity.java
/** * Called, if data model reports changes in data set * data == Boolean.TRUE, if user logs in and Boolean.FALSE, if user logs out * @param observable model to be observed * @param data data sent from the model/*from www . j av a 2 s.c o m*/ */ @Override public void update(Observable observable, Object data) { // Check whether model returns log in or log off by user Boolean anmeldung = (Boolean) data; if (anmeldung.equals(Boolean.TRUE)) { // Show profile on log in wechsleFragment(FragmentProfil.newInstance(model)); } else { // return to map on log off wechsleFragment(FragmentKarte.newInstance(this, model)); Toast.makeText(this, R.string.meldung_abmelden, Toast.LENGTH_SHORT).show(); } }
From source file:org.apereo.portal.url.MaxInactiveInterceptor.java
@Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { final HttpSession session = request.getSession(false); if (session == null) { return true; }/* w w w . jav a 2 s . c o m*/ // Now see if authentication was successful... final IPerson person = this.personManager.getPerson((HttpServletRequest) request); if (person == null) { return true; } // Check if the session max inactive value has already been set Boolean isAlreadySet = (Boolean) person.getAttribute(this.SESSION_MAX_INACTIVE_SET_ATTR); if (isAlreadySet != null && isAlreadySet.equals(Boolean.TRUE)) { if (log.isDebugEnabled()) { log.debug("Session.setMaxInactiveInterval() has already been determined for user '" + person.getAttribute(IPerson.USERNAME) + "'"); } return true; } final ISecurityContext securityContext = person.getSecurityContext(); if (securityContext != null && securityContext.isAuthenticated()) { // We have an authenticated user... let's see if any MAX_INACTIVE settings apply... IAuthorizationPrincipal principal = authorizationService .newPrincipal((String) person.getAttribute(IPerson.USERNAME), IPerson.class); Integer rulingGrant = null; Integer rulingDeny = null; IPermission[] permissions = authorizationService.getAllPermissionsForPrincipal(principal, IPermission.PORTAL_SYSTEM, "MAX_INACTIVE", null); assert (permissions != null); if (permissions.length == 0) { // No max inactive permission set for this user if (log.isInfoEnabled()) { log.info("No MAX_INACTIVE permissions apply to user '" + person.getAttribute(IPerson.USERNAME) + "'"); } person.setAttribute(this.SESSION_MAX_INACTIVE_SET_ATTR, Boolean.TRUE); return true; } for (IPermission p : permissions) { // First be sure the record applies currently... long now = System.currentTimeMillis(); if (p.getEffective() != null && p.getEffective().getTime() > now) { // It's *TOO EARLY* for this record... move on. continue; } if (p.getExpires() != null && p.getExpires().getTime() < now) { // It's *TOO LATE* for this record... move on. continue; } if (p.getType().equals(IPermission.PERMISSION_TYPE_GRANT)) { try { Integer grantEntry = Integer.valueOf(p.getTarget()); if (rulingGrant == null || grantEntry.intValue() < 0 /* Any negative number trumps all */ || rulingGrant.intValue() < grantEntry.intValue()) { rulingGrant = grantEntry; } } catch (NumberFormatException nfe) { log.warn("Invalid MAX_INACTIVE permission grant '" + p.getTarget() + "'; target must be an integer value."); } } else if (p.getType().equals(IPermission.PERMISSION_TYPE_DENY)) { try { Integer denyEntry = Integer.valueOf(p.getTarget()); if (rulingDeny == null || rulingDeny.intValue() > denyEntry.intValue()) { rulingDeny = denyEntry; } } catch (NumberFormatException nfe) { log.warn("Invalid MAX_INACTIVE permission deny '" + p.getTarget() + "'; target must be an integer value."); } } else { log.warn("Unknown permission type: " + p.getType()); } } if (rulingDeny != null && rulingDeny.intValue() < 0) { // Negative MaxInactiveInterval values mean the session never // times out, so a negative DENY is somewhat nonsensical... just // clear it. log.warn("A MAX_INACTIVE DENY entry improperly specified a negative target: " + rulingDeny.intValue()); rulingDeny = null; } if (rulingGrant != null || rulingDeny != null) { // We only want to intervene if there's some actual value // specified... otherwise we'll just let the container settings //govern. int maxInactive = rulingGrant != null ? rulingGrant.intValue() : 0; // If rulingGrant is null, rulingDeny won't be... if (rulingDeny != null) { // Applying DENY entries is tricky b/c GRANT entries may be negative... int limit = rulingDeny.intValue(); if (maxInactive >= 0) { maxInactive = limit < maxInactive ? limit : maxInactive; } else { // The best grant was negative (unlimited), so go with limit... maxInactive = limit; } } // Apply the specified setting... session.setMaxInactiveInterval(maxInactive); person.setAttribute(this.SESSION_MAX_INACTIVE_SET_ATTR, Boolean.TRUE); if (log.isInfoEnabled()) { log.info("Setting maxInactive to '" + maxInactive + "' for user '" + person.getAttribute(IPerson.USERNAME) + "'"); } } } return true; }
From source file:edu.sjsu.cmpe275.project.service.SearchRoomAvailability.java
public List<Room> query(Date checkinDate, Date checkoutDate, int roomNum, Integer roomType, Boolean smoking) { List<Room> result = new LinkedList<Room>(); //TODO//from w w w. j a v a 2 s . co m List<Room> rooms = roomDao.getAllRoom(); for (Room r : rooms) { if (roomType != null && !roomType.equals(r.getRoomType())) { continue; } if (smoking != null && !smoking.equals(r.getSmoking())) { continue; } if (isAvailable(r, checkinDate, checkoutDate)) { result.add(r); } } if (result.size() < roomNum) { //No enough vacant room for this query return null; } return result; }
From source file:bql.util.JsonComparator.java
private boolean isEqualsBoolean(Boolean a, Boolean b) { if (a == null ^ b == null) { return false; } else if (a == null && b == null) { return true; }// ww w . j a v a 2 s . c o m return a.equals(b); }
From source file:com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkApiImporter.java
protected void updateMethod(RestApi api, Method method, String type, String name, boolean required) { String expression = getExpression("method", "request", type, name); Map<String, Boolean> requestParameters = method.getRequestParameters(); Boolean requestParameter = requestParameters == null ? null : requestParameters.get(expression); if (requestParameter != null && requestParameter.equals(required)) { return;/*from w ww . j av a2 s . co m*/ } LOG.info(format("Creating method parameter for api %s and method %s with name %s", api.getId(), method.getHttpMethod(), expression)); method.updateMethod(createPatchDocument( createAddOperation("/requestParameters/" + expression, getStringValue(required)))); }
From source file:net.kamhon.ieagle.function.user.vo.UserMenu.java
@Transient public String getAcrud() { if (StringUtils.isBlank(accessCode)) { return ""; }//from w w w . j av a 2s .com Boolean t = new Boolean(true); String s = ""; s += t.equals(adminMode) ? "Y" : "N"; s += t.equals(createMode) ? "Y" : "N"; s += t.equals(readMode) ? "Y" : "N"; s += t.equals(updateMode) ? "Y" : "N"; s += t.equals(deleteMode) ? "Y" : "N"; return s; }
From source file:org.castor.cache.distributed.EHCache.java
/** * {@inheritDoc}//from w w w . j a v a 2 s . co m */ @SuppressWarnings("unchecked") public V get(final Object key) { Object result = null; try { Object elementInCache = _getMethod.invoke(_cache, new Object[] { key }); if (elementInCache == null) { return null; } Boolean isExpired = (Boolean) _isExpiredMethod.invoke(elementInCache, (Object[]) null); if (isExpired.equals(Boolean.FALSE)) { result = _getValueMethod.invoke(elementInCache, (Object[]) null); } } catch (Exception e) { String msg = "Failed to call method on EHCache instance: " + e.getMessage(); LOG.error(msg, e); throw new IllegalStateException(e.getMessage()); } return (V) result; }
From source file:com.twitter.heron.scheduler.SubmitterMain.java
protected boolean validateSubmit(SchedulerStateManagerAdaptor adaptor, String topologyName) { // Check whether the topology has already been running Boolean isTopologyRunning = adaptor.isTopologyRunning(topologyName); if (isTopologyRunning != null && isTopologyRunning.equals(Boolean.TRUE)) { LOG.severe("Topology already exists"); return false; }// w w w . ja v a 2 s . c o m return true; }
From source file:org.talend.designer.core.model.components.Expression.java
private static boolean evaluateSimpleExpression(String simpleExpression, List<? extends IElementParameter> listParam, ElementParameter currentParam) { boolean showParameter = false; String test = null;//from w w w. j a v a2 s .c o m if (simpleExpression.contains(EQUALS)) { test = EQUALS; } else if (simpleExpression.contains(NOT_EQUALS)) { test = NOT_EQUALS; } else if (simpleExpression.contains(GREAT_THAN)) { test = GREAT_THAN; } else if (simpleExpression.contains(LESS_THAN)) { test = LESS_THAN; } if ((simpleExpression.contains(" IN [") || //$NON-NLS-1$ simpleExpression.contains(" IN[")) && simpleExpression.endsWith("]")) { //$NON-NLS-1$ //$NON-NLS-2$ return evaluateInExpression(simpleExpression, listParam); } if ((simpleExpression.contains("DISTRIB["))) { //$NON-NLS-1$ return evaluateDistrib(simpleExpression, listParam, currentParam); } List<String> paraNames = getParaNamesFromIsShowFunc(simpleExpression); if (paraNames.size() > 0) { // Here only be one isShow() function since it has been already split. String paraName = paraNames.get(0); try { checkIsShowLoop(paraName, simpleExpression, listParam, currentParam, null); } catch (Exception e) { ExceptionHandler.process(e); return false; } for (IElementParameter param : listParam) { if (paraName != null && paraName.equals(param.getName())) { return param.isShow(param.getShowIf(), param.getNotShowIf(), listParam); } } } if (test == null) { throwUnsupportedExpression(simpleExpression, currentParam); return false; } String[] strings = simpleExpression.split(test); String variableName = null, variableValue = null; for (String string2 : strings) { String string = string2.trim(); if (string.contains("'")) { // value //$NON-NLS-1$ variableValue = string; variableValue = variableValue.substring(1, string.lastIndexOf("'")); //$NON-NLS-1$ } else { variableName = string; } } /* * this is only for Current OS condition. */ if (variableName != null && EParameterName.CURRENT_OS.getName().equals(variableName)) { if (variableValue != null) { if (EQUALS.endsWith(test)) { return checkCurrentOS(variableValue); } else if (NOT_EQUALS.equals(test)) { return !checkCurrentOS(variableValue); } } } if (listParam == null) { return false; } /* * this only used to check is EE version or not */ if ("IS_STUDIO_EE_VERSION".equals(variableName)) { //$NON-NLS-1$ boolean isTIS = PluginChecker.isTIS(); if ("true".equals(variableValue)) { //$NON-NLS-1$ return isTIS; } else { return !isTIS; } } /* * this only used to check is IPAAS Components are Loaded or not */ if ("IS_STUDIO_IPAAS_VERSION".equals(variableName)) { //$NON-NLS-1$ boolean isIPaas = PluginChecker.isIPaasPluginLoaded(); if ("true".equals(variableValue)) { //$NON-NLS-1$ return isIPaas; } else { return !isIPaas; } } // 3 levels of variable name accepted maximum (ex: MY_VAR.TABLE.FIELD == 'test') String[] varNames; varNames = StringUtils.split(variableName, '.'); // wyang: only for bug:9055, to search the related Node, for example tFTPGet wants to check tFTPConnection info // variableName like: #LINK@NODE.CONNECTION.SFTP ----->it is a checkbox in tFTPConnection // #LINK@NODE, #PREVIOUS@NODE, #NEXT@NODE ----->implement them later if ((variableName != null) && (variableValue != null)) { if (varNames[0].equals("#LINK@NODE")) { //$NON-NLS-1$ INode node = null; if (currentParam != null && currentParam.getElement() instanceof INode) { node = (INode) currentParam.getElement(); } else if (currentParam == null) { if (listParam != null && listParam.size() > 0) { IElement element = listParam.get(0).getElement(); if (element instanceof INode) { node = (INode) element; } } } if (node != null) { String relatedNodeName = ElementParameterParser.getValue(node, "__" + varNames[1] + "__"); //$NON-NLS-1$ //$NON-NLS-2$ // if relatedNodeName is empty, maybe means this property have not been setted if (relatedNodeName != null && !relatedNodeName.trim().isEmpty()) { List<? extends INode> generatingNodes = node.getProcess().getGeneratingNodes(); for (INode aNode : generatingNodes) { if (aNode.getUniqueName().equals(relatedNodeName)) { simpleExpression = simpleExpression.replace(varNames[0] + "." + varNames[1] + ".", //$NON-NLS-1$//$NON-NLS-2$ ""); //$NON-NLS-1$ List<? extends IElementParameter> elementParameters = aNode.getElementParameters(); // let's supose the currentParam = null, there won't want deal with the TABLE field, // only deal with LIST/CHECKBOX return evaluate(simpleExpression, elementParameters); } } } } } /* * TESB-6240 GangLiu Test the connection configuration. */ else if ("#LINK@CONNECTOR".equals(varNames[0])) { //$NON-NLS-1$ if (listParam != null && listParam.size() > 0) { IElement element = listParam.get(0).getElement(); if (element != null && element instanceof INode) { INode node = (INode) element; if (varNames.length > 2 && varNames[1] != null && varNames[2] != null) { // read in/out connection type accounts List<? extends IConnection> connections = new ArrayList<IConnection>(); if ("IN".equals(varNames[1]) || "OUT".equals(varNames[1])) { //$NON-NLS-1$ //$NON-NLS-2$ if ("IN".equals(varNames[1])) { //$NON-NLS-1$ if ("ANY".equals(varNames[2])) { //$NON-NLS-1$ connections = node.getIncomingConnections(); } else { connections = node .getIncomingConnections(EConnectionType.valueOf(varNames[2])); } } else { if ("ANY".equals(varNames[2])) { //$NON-NLS-1$ connections = node.getOutgoingConnections(); } else { connections = node .getOutgoingConnections(EConnectionType.valueOf(varNames[2])); } } try { int connSize = connections.size(); int targetNumber = Integer.parseInt(variableValue); if (GREAT_THAN.equals(test)) { return connSize > targetNumber; } else if (LESS_THAN.equals(test)) { return connSize < targetNumber; } else if (EQUALS.equals(test)) { return connSize == targetNumber; } else if (NOT_EQUALS.equals(test)) { return connSize != targetNumber; } } catch (Exception e) { } } else { // read specific connection parameter connections = node.getOutgoingConnections(EConnectionType.valueOf(varNames[1])); for (IConnection c : connections) { IElementParameter elementParameter = c.getElementParameter(varNames[2]); if (variableValue.equals(elementParameter.getValue())) { return true; } } } } } } return false; } // End of TESB-6240 else if ("#NODE@IN".equals(varNames[0])) { //$NON-NLS-1$ if (listParam != null && listParam.size() > 0) { IElement element = listParam.get(0).getElement(); if (element != null && element instanceof IConnection) { INode sourceNode = ((IConnection) element).getSource(); // change from: #NODE@IN.SUBTREE_START == 'false' // to: SUBTREE_START == 'false' simpleExpression = simpleExpression.replace(varNames[0] + ".", ""); //$NON-NLS-1$ //$NON-NLS-2$ return evaluate(simpleExpression, sourceNode.getElementParameters()); } } } else if ("#NODE@OUT".equals(varNames[0])) { //$NON-NLS-1$ if (listParam != null && listParam.size() > 0) { IElement element = listParam.get(0).getElement(); if (element != null && element instanceof IConnection) { INode sourceNode = ((IConnection) element).getTarget(); // change from: #NODE@OUT.END_OF_FLOW == 'false' // to: END_OF_FLOW == 'false' simpleExpression = simpleExpression.replace(varNames[0] + ".", ""); //$NON-NLS-1$ //$NON-NLS-2$ return evaluate(simpleExpression, sourceNode.getElementParameters()); } } } } if ((variableName != null) && (variableValue != null)) { for (IElementParameter param : listParam) { if (param.getName().equals(varNames[0])) { IElementParameter testedParameter = param; Object value = null; boolean found = false; if (param.getFieldType().equals(EParameterFieldType.TABLE)) { List<Map<String, Object>> tableValues = (List<Map<String, Object>>) param.getValue(); if (currentParam == null) { continue; } if (tableValues.size() <= currentParam.getCurrentRow()) { break; } Map<String, Object> currentRow = tableValues.get(currentParam.getCurrentRow()); if (currentRow.containsKey(varNames[1])) { for (Object curObj : param.getListItemsValue()) { if (curObj instanceof IElementParameter) { IElementParameter testParam = (IElementParameter) curObj; if (testParam.getName().equals(varNames[1])) { testedParameter = testParam; break; } } } if (varNames.length == 2) { // simple value value = currentRow.get(varNames[1]); } else { if ("TYPE".equals(varNames[2])) { //$NON-NLS-1$ IMetadataTable baseTable = null; IMetadataColumn baseColumn = null; INode node; Object obj = currentRow.get(testedParameter.getName()); String columnName = ""; //$NON-NLS-1$ if (obj instanceof String) { columnName = (String) obj; } else if (obj instanceof Integer) { int index = (Integer) obj; if (index < testedParameter.getListItemsDisplayName().length && index >= 0) { columnName = testedParameter.getListItemsDisplayName()[(Integer) obj]; } } if (currentParam.getElement() instanceof INode) { node = (INode) currentParam.getElement(); switch (testedParameter.getFieldType()) { case COLUMN_LIST: baseTable = node.getMetadataList().get(0); break; case PREV_COLUMN_LIST: IConnection connection = null; for (int i = 0; i < node.getIncomingConnections().size(); i++) { IConnection curConnec = node.getIncomingConnections().get(i); if (curConnec.getLineStyle() == EConnectionType.FLOW_MAIN) { connection = curConnec; break; } } if (connection != null) { baseTable = connection.getMetadataTable(); } break; case LOOKUP_COLUMN_LIST: List<IConnection> refConnections = new ArrayList<IConnection>(); for (int i = 0; i < node.getIncomingConnections().size(); i++) { IConnection curConnec = node.getIncomingConnections().get(i); if (curConnec.getLineStyle() == EConnectionType.FLOW_REF) { refConnections.add(curConnec); } } for (IConnection curConnec : refConnections) { IMetadataTable table = curConnec.getMetadataTable(); for (IMetadataColumn column : table.getListColumns()) { String name = curConnec.getName() + "." + column.getLabel(); //$NON-NLS-1$ if (name.equals(columnName)) { baseColumn = column; } } } break; default: } if (baseTable != null) { for (IMetadataColumn column : baseTable.getListColumns()) { if (column.getLabel().equals(columnName)) { baseColumn = column; break; } } } if (baseColumn != null) { switch (LanguageManager.getCurrentLanguage()) { case JAVA: value = JavaTypesManager.getTypeToGenerate( baseColumn.getTalendType(), baseColumn.isNullable()); break; default: value = baseColumn.getTalendType(); } if (value.equals(variableValue)) { found = true; } } } } } } } else if (param.getFieldType().equals(EParameterFieldType.PROPERTY_TYPE) || param.getFieldType().equals(EParameterFieldType.SCHEMA_TYPE) || param.getFieldType().equals(EParameterFieldType.QUERYSTORE_TYPE) || param.getFieldType().equals(EParameterFieldType.ENCODING_TYPE)) { boolean child = false; Map<String, IElementParameter> childParameters = param.getChildParameters(); if ("PROPERTY".equals(param.getName()) //$NON-NLS-1$ || EParameterFieldType.PROPERTY_TYPE == param.getFieldType()) { if (childParameters != null) { IElementParameter iElementParameter = childParameters.get("PROPERTY_TYPE"); //$NON-NLS-1$ if (iElementParameter != null) { Object value2 = iElementParameter.getValue(); if (variableValue.equals(value2.toString())) { child = true; found = true; value = value2.toString(); } } } } if (varNames.length > 1 && varNames[1] != null) { IElementParameter tempParam = childParameters.get(varNames[1]); if (tempParam != null) { value = tempParam.getValue(); if (value.equals(variableValue)) { found = true; } child = true; } } if (!child) { value = testedParameter.getValue(); } } else { value = testedParameter.getValue(); } if (value instanceof Integer) { if (((Integer) value) < testedParameter.getListItemsValue().length) { value = testedParameter.getListItemsValue()[(Integer) value]; } } if (value instanceof String) { if (variableValue.equals(value)) { found = true; } else if (testedParameter.getListItemsValue() instanceof Object[]) { Object[] values = testedParameter.getListItemsValue(); for (int i = 0; i < values.length && !found; i++) { if (values[i].equals(value)) { String variableCode = testedParameter.getListItemsDisplayCodeName()[i]; if (variableCode.equals(variableValue)) { found = true; } } } } } else if (value instanceof Boolean) { Boolean tmpValue = new Boolean(variableValue); if (tmpValue.equals(value)) { found = true; } } if (found) { if (test.equals(EQUALS)) { showParameter = true; } } else { if (test.equals(NOT_EQUALS)) { showParameter = true; } } break; } } if (currentParam != null && "INCOMING_LINK_TYPE".equals(variableName)) {//$NON-NLS-1$ IElement element = currentParam.getElement(); if (element != null && element instanceof INode) { INode node = (INode) element; if (node.getComponent() != null && "tPigLoad".equals(node.getComponent().getName())) { //$NON-NLS-1$ List<IConnection> connectionsInputs = (List<IConnection>) node.getIncomingConnections(); for (IConnection connection : connectionsInputs) { if (connection.isActivate() && connection.getLineStyle().hasConnectionCategory(IConnectionCategory.MAIN) && variableValue.toUpperCase().equals(connection.getConnectorName())) { showParameter = true; } } } } } } return showParameter; }