001/* 002 * Copyright 2019 Anyware Services 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.ametys.web.frontoffice.search; 017 018/** 019 * This class is here to propose workarounds for bugs the nasty Ametys developers introduced 😈 020 */ 021public final class Workarounds 022{ 023 private Workarounds() 024 { } 025 026 /** 027 * For https://issues.ametys.org/browse/CMS-9541 028 * <br>When fixed, remove this class. 029 * <br>What is happening is that currently, Ametys cannot see the 030 * difference between an empty value for an optional parameter (not present in purpose) 031 * and the absence of the value because it is a 'new' parameter (user never had the opportunity to fill it). 032 * <br>Thus, as the optional parameter defines a default value, when editing the service, the default value 033 * is automatically filled for those parameters which are empty whereas we do not want. 034 */ 035 public static final class OptionalParameterValue 036 { 037 /** 038 * Returns <code>true</code> if the value is considered non-empty. 039 * <br>Because of the workaround, 0 actually means "empty" 040 * @param value The value got from the storage 041 * @return <code>true</code> if the value is considered non-empty 042 */ 043 public static final boolean isNotEmpty(Integer value) 044 { 045 return value != null && value != 0; 046 } 047 } 048} 049