[[visibility]]
= Visibility

:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR  CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
:page-partial:

== Property or Collection

To hide a property or collection:

[source,java]
----
import lombok.Getter;
import lombok.Setter;

@Getter @Setter
private String status;

public boolean hideStatus() {   // <.>
    // ...
}
----
<.> "hide" prefix, suffix matches up with the property name, and returns a `boolean`.
Returns `true` to hide the property, `false` means it is visible


== Object Action

An object action can be hidden similarly:

[source,java]
----
public Customer placeOrder(Product p, int quantity) {
    // ...
}
public boolean hidePlaceOrder() {                         // <.>
    // ...
}
----
<.> "hide" prefix, suffix matches up with the action's name, and takes no parameters.
Returns `true` to hide the action, `false` means it is visible



== Action Parameter

It is also possible to hide an action parameter, based on the value of some other earlier parameter:
Each `hideNXxx()` method can declare parameters for the previous N-1 parameters, though it need not declare them all.

For example:

[source,java]
----
public class Order {
    public Order shipTo(
            boolean sameAsBillingAddress,
            String addressLine1,
            String addressLine2,
            String addressCity,
            String addressPostalCode,
            String addressCountry
    ) {
        // ...
    }
    public boolean hide1ShipTo(boolean sameAsBillingAddress) {  // <.>
        return sameAsBillingAddress;
    }
    public boolean hide2ShipTo(boolean sameAsBillingAddress) {
        return sameAsBillingAddress;
    }
    public boolean hide3ShipTo(boolean sameAsBillingAddress) {
        return sameAsBillingAddress;
    }
    public boolean hide4ShipTo(boolean sameAsBillingAddress) {
        return sameAsBillingAddress;
    }
    public boolean hide5ShipTo(boolean sameAsBillingAddress) {
        return sameAsBillingAddress;
    }
}
----
<.> "hide" prefix, N-th param, suffix matches action's name, parameters are subset up to Nth, same type.
Returns `true` to hide the action parameter, `false` means it is visible

In this case, the user can use the `shipTo(...)` action to specify where to ship the `Order` to.
However, if they check the first boolean parameter (ie, to ship the `Order` to the billing address already held on file), then the remaining parameters will all be hidden.


== See also

* xref:refguide:applib-methods:prefixes.adoc#hide[hide...()] method prefix



