List of usage examples for org.apache.commons.lang BooleanUtils isFalse
public static boolean isFalse(Boolean bool)
Checks if a Boolean
value is false
, handling null
by returning false
.
BooleanUtils.isFalse(Boolean.TRUE) = false BooleanUtils.isFalse(Boolean.FALSE) = true BooleanUtils.isFalse(null) = false
From source file:org.sonar.java.checks.ProtectedMemberInFinalClassCheck.java
private void checkMember(Tree member) { if (member.is(Kind.VARIABLE)) { VariableTree variableTree = (VariableTree) member; checkVariableCompliance(variableTree); } else if (member.is(Kind.METHOD)) { MethodTreeImpl methodTree = (MethodTreeImpl) member; if (BooleanUtils.isFalse(methodTree.isOverriding())) { checkMethodCompliance(methodTree); }//from ww w . j av a 2s . c o m } }
From source file:org.sonar.java.checks.RawExceptionCheck.java
private static boolean isNotOverriden(MethodTree tree) { return BooleanUtils.isFalse(((MethodTreeImpl) tree).isOverriding()); }
From source file:org.sonar.java.checks.ThreadStartedInConstructorCheck.java
@Override public void visitNode(Tree tree) { if (hasSemantic()) { if (tree.is(Tree.Kind.CLASS)) { inMethodOrStaticInitializerOrFinalClass.push(((ClassTree) tree).symbol().isFinal()); } else if (tree.is(Tree.Kind.METHOD, Tree.Kind.STATIC_INITIALIZER)) { inMethodOrStaticInitializerOrFinalClass.push(Boolean.TRUE); } else if (BooleanUtils.isFalse(inMethodOrStaticInitializerOrFinalClass.peek()) && THREAD_START.matches((MethodInvocationTree) tree)) { reportIssue(MethodsHelper.methodName((MethodInvocationTree) tree), "Move this \"start\" call to another method."); }//ww w. j a v a 2s. com } }
From source file:org.sonar.java.checks.unused.UnusedMethodParameterCheck.java
private static boolean isOverriding(MethodTree tree) { // if overriding cannot be determined, we consider it is overriding to avoid FP. return !BooleanUtils.isFalse(((MethodTreeImpl) tree).isOverriding()); }
From source file:org.sonar.server.issue.index.IssueIndex.java
private Map<String, QueryBuilder> createFilters(IssueQuery query) { Map<String, QueryBuilder> filters = new HashMap<>(); filters.put("__authorization", createAuthorizationFilter(query.checkAuthorization())); // Issue is assigned Filter if (BooleanUtils.isTrue(query.assigned())) { filters.put(IS_ASSIGNED_FILTER, existsQuery(IssueIndexDefinition.FIELD_ISSUE_ASSIGNEE)); } else if (BooleanUtils.isFalse(query.assigned())) { filters.put(IS_ASSIGNED_FILTER,// www .j ava 2s . com boolQuery().mustNot(existsQuery(IssueIndexDefinition.FIELD_ISSUE_ASSIGNEE))); } // Issue is Resolved Filter String isResolved = "__isResolved"; if (BooleanUtils.isTrue(query.resolved())) { filters.put(isResolved, existsQuery(IssueIndexDefinition.FIELD_ISSUE_RESOLUTION)); } else if (BooleanUtils.isFalse(query.resolved())) { filters.put(isResolved, boolQuery().mustNot(existsQuery(IssueIndexDefinition.FIELD_ISSUE_RESOLUTION))); } // Field Filters filters.put(IssueIndexDefinition.FIELD_ISSUE_KEY, createTermsFilter(IssueIndexDefinition.FIELD_ISSUE_KEY, query.issueKeys())); filters.put(IssueIndexDefinition.FIELD_ISSUE_ASSIGNEE, createTermsFilter(IssueIndexDefinition.FIELD_ISSUE_ASSIGNEE, query.assignees())); addComponentRelatedFilters(query, filters); filters.put(IssueIndexDefinition.FIELD_ISSUE_LANGUAGE, createTermsFilter(IssueIndexDefinition.FIELD_ISSUE_LANGUAGE, query.languages())); filters.put(IssueIndexDefinition.FIELD_ISSUE_TAGS, createTermsFilter(IssueIndexDefinition.FIELD_ISSUE_TAGS, query.tags())); filters.put(IssueIndexDefinition.FIELD_ISSUE_TYPE, createTermsFilter(IssueIndexDefinition.FIELD_ISSUE_TYPE, query.types())); filters.put(IssueIndexDefinition.FIELD_ISSUE_RESOLUTION, createTermsFilter(IssueIndexDefinition.FIELD_ISSUE_RESOLUTION, query.resolutions())); filters.put(IssueIndexDefinition.FIELD_ISSUE_AUTHOR_LOGIN, createTermsFilter(IssueIndexDefinition.FIELD_ISSUE_AUTHOR_LOGIN, query.authors())); filters.put(IssueIndexDefinition.FIELD_ISSUE_RULE_KEY, createTermsFilter(IssueIndexDefinition.FIELD_ISSUE_RULE_KEY, query.rules())); filters.put(IssueIndexDefinition.FIELD_ISSUE_SEVERITY, createTermsFilter(IssueIndexDefinition.FIELD_ISSUE_SEVERITY, query.severities())); filters.put(IssueIndexDefinition.FIELD_ISSUE_STATUS, createTermsFilter(IssueIndexDefinition.FIELD_ISSUE_STATUS, query.statuses())); filters.put(IssueIndexDefinition.FIELD_ISSUE_ORGANIZATION_UUID, createTermFilter(IssueIndexDefinition.FIELD_ISSUE_ORGANIZATION_UUID, query.organizationUuid())); addDatesFilter(filters, query); return filters; }
From source file:org.sonar.server.qualitygate.QualityGateConditionsUpdater.java
private static boolean isAlertable(MetricDto metric) { return isAvailableForInit(metric) && BooleanUtils.isFalse(metric.isHidden()); }
From source file:org.sparkcommerce.admin.server.service.handler.SkuCustomPersistenceHandler.java
/** * <p>Creates an individual property for the specified product option. This should set up an enum field whose values will * be the option values for this option. This is useful when you would like to display each product option in as its * own field in a grid so that you can further filter by product option values.</p> * <p>In order for these fields to be utilized property on the fetch, in the GWT frontend you must use the * for your datasource.</p>//from www . j a v a 2s .co m * * @param option * @param order * @return */ public static FieldMetadata createIndividualOptionField(ProductOption option, int order) { BasicFieldMetadata metadata = new BasicFieldMetadata(); List<ProductOptionValue> allowedValues = option.getAllowedValues(); if (CollectionUtils.isNotEmpty(allowedValues)) { metadata.setFieldType(SupportedFieldType.EXPLICIT_ENUMERATION); metadata.setMutable(true); metadata.setInheritedFromType(SkuImpl.class.getName()); metadata.setAvailableToTypes(new String[] { SkuImpl.class.getName() }); metadata.setForeignKeyCollection(false); metadata.setMergedPropertyType(MergedPropertyType.PRIMARY); //Set up the enumeration based on the product option values String[][] optionValues = new String[allowedValues.size()][2]; for (int i = 0; i < allowedValues.size(); i++) { ProductOptionValue value = option.getAllowedValues().get(i); optionValues[i][0] = value.getId().toString(); optionValues[i][1] = value.getAttributeValue(); } metadata.setEnumerationValues(optionValues); metadata.setName(PRODUCT_OPTION_FIELD_PREFIX + option.getId()); metadata.setFriendlyName(option.getLabel()); metadata.setGroup("productOption_group"); metadata.setGroupOrder(-1); metadata.setOrder(order); metadata.setExplicitFieldType(SupportedFieldType.UNKNOWN); metadata.setProminent(false); metadata.setVisibility(VisibilityEnum.FORM_EXPLICITLY_SHOWN); metadata.setSparkEnumeration(""); metadata.setReadOnly(false); metadata.setRequiredOverride(BooleanUtils.isFalse(option.getRequired())); return metadata; } return null; }
From source file:org.tsm.concharto.web.eventsearch.EventSearchFormValidator.java
public void validate(Object target, Errors errors) { EventSearchForm eventSearchForm = (EventSearchForm) target; //if the geocode failed if (BooleanUtils.isFalse(eventSearchForm.getIsGeocodeSuccess())) { errors.rejectValue("where", "failedGeocode.eventSearch.where", new Object[] { eventSearchForm.getWhere() }, null); }/* w w w.ja va2s .co m*/ //begin can't be after end if (eventSearchForm.getWhen() != null) { if (eventSearchForm.getWhen().getBegin().getDate() .after(eventSearchForm.getWhen().getEnd().getDate())) { errors.rejectValue("when", "beginAfterEnd.when", new Object[] { eventSearchForm.getWhen() }, null); } } }
From source file:org.tsm.concharto.web.eventsearch.SearchHelper.java
/** * Search for events and return results in the model. Some search results are also put in the form * so that the javascript functions may use them. * //from w w w . j ava 2 s . c o m * @param mapKey google api key * @param request request * @param model model containing search results * @param eventSearchForm form containing search parameters and search results * @return a list of Event objects */ @SuppressWarnings("unchecked") public List<Event> doSearch(String mapKey, HttpServletRequest request, Map model, EventSearchForm eventSearchForm) { /* * 1. Get the lat-long bounding box of whatever zoom * level we are at. 2. Parse the time field to extract a time range 3. * Do a search to find the count of all events within that text filter, * time range and bounding box * TODO cache the total results if nothing has changed (e.g. pagination) */ List<Event> events; Long totalResults; Integer firstRecord; if (eventSearchForm.getDisplayEventId() != null) { Event event = eventSearchService.findById(eventSearchForm.getDisplayEventId()); events = new ArrayList<Event>(); events.add(event); eventSearchForm.setMapCenter(event.getTsGeometry().getGeometry().getCentroid()); //Don't override the zoom for polylines or polygons no matter what. Otherwise, there is too //much opportunity for confusion. For example, the centroid of the polyline may be nowhere //near the border in which case you won't see the line at all. if (event.getTsGeometry().getGeometry() instanceof Point) { eventSearchForm.setMapCenterOverride(true); eventSearchForm.setZoomOverride(true); } else { eventSearchForm.setMapCenterOverride(false); eventSearchForm.setZoomOverride(false); } eventSearchForm.setMapZoom(event.getZoomLevel()); eventSearchForm.setMapType(event.getMapType()); totalResults = 1L; firstRecord = 0; //now remove the id from the form - we don't want to get stuck forever showing this event //the browser javascript still needs the event id so it can crate a linkHere url, so we make //a copy of the id eventSearchForm.setLinkHereEventId(eventSearchForm.getDisplayEventId()); eventSearchForm.setDisplayEventId(null); } else { eventSearchForm.setLinkHereEventId(null); eventSearchForm.setDisplayEventId(null); if (eventSearchForm.getMapCenter() == null) { //geocode try { geocode(mapKey, request, eventSearchForm); } catch (IOException e) { //TODO, perhaps some better error handling here?? log.info("Exception geocoding location " + eventSearchForm.getWhere() + e); } } //we are ok to go if IsGeocodeSuccess is null or True if (!BooleanUtils.isFalse(eventSearchForm.getIsGeocodeSuccess())) { firstRecord = DisplayTagHelper.getFirstRecord(request, DISPLAYTAG_TABLE_ID, DISPLAYTAG_PAGESIZE); LatLngBounds bounds = getBounds(eventSearchForm); SearchParams params = new SearchParams(); params.setTextFilter(eventSearchForm.getWhat()); params.setUserTag(eventSearchForm.getUserTag()); params.setTimeRange(eventSearchForm.getWhen()); params.setVisibility(getVisibility(eventSearchForm)); params.setCatalog(CatalogUtil.getCatalog(request)); //note these are opposites.. a value of null or false = false, true=true params.setIncludeTimeRangeOverlaps( !BooleanUtils.isTrue(eventSearchForm.getExcludeTimeRangeOverlaps())); events = eventSearchService.search(DISPLAYTAG_PAGESIZE, firstRecord, bounds, params); //for debugging //addDebugBoundingBox(events, bounds); totalResults = eventSearchService.getCount(bounds, params); } else { //failed geocode, no points events = new ArrayList<Event>(); totalResults = 0L; firstRecord = 0; } } prepareModel(model, events, totalResults, firstRecord); //NOTE: we are putting the events into the command so that the page javascript //functions can properly display them using google's mapping API List<Event> renderedEvents = renderWiki(events, request); eventSearchForm.setSearchResults(JSONFormat.toJSON(renderedEvents)); setupPageTitle(request, eventSearchForm, model, events); return events; }
From source file:org.tsm.concharto.web.eventsearch.SearchHelper.java
/** * Find the search bounding box. It depends on the map center and zoom level. * @param eventSearchForm search form/*from w w w . ja v a2s.c o m*/ * @return LatLngBounds search bounding box */ private LatLngBounds getBounds(EventSearchForm eventSearchForm) { //if we are below a certain zoom level, we will still search a wider area LatLngBounds bounds = null; if ((StringUtils.isEmpty(eventSearchForm.getWhere())) && BooleanUtils.isFalse(eventSearchForm.getLimitWithinMapBounds())) { //when they specify fit view to all results, we don't want a bounding box, unless //they also specify a place, in which case the geocode takes precedence return null; } //if we already have bounds if (hasBounds(eventSearchForm)) { //if there are no bounds or the user explicitly said to use those bounds if ((!zoomedInTooLow(eventSearchForm) || (BooleanUtils.isTrue(eventSearchForm.getLimitWithinMapBounds())))) { bounds = new LatLngBounds(eventSearchForm.getBoundingBoxSW(), eventSearchForm.getBoundingBoxNE()); } //when we are zoomed in real low we want to search more than just the visible map, instead //use the a wider search radius else { bounds = searchBoxBounds(eventSearchForm); } } else if (null != eventSearchForm.getWhere()) { //there is a location, but no bounds, so we have to make them bounds = searchBoxBounds(eventSearchForm); } return bounds; }