= TableColumnOrderService
: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.

Provides the ability to reorder columns in both parented- and standalone tables.

If a property is excluded from the returned list, then no column will be rendered, so the API can also be used to suppress columns completely.

There can be multiple implementations of this service registered, ordered as per the Spring _org.springframework.core.annotation.Order_ annotation (or equivalent). The result of the first service implementation to return a non- `null` value will be used.

If all provided implementations return `null` , then the framework will fallback to a default implementation.

The similar xref:refguide:applib:index/services/tablecol/TableColumnVisibilityService.adoc[TableColumnVisibilityService] SPI is the preferred way to suppress columns. As noted above, this xref:refguide:applib:index/services/tablecol/TableColumnOrderService.adoc[TableColumnOrderService] can also be used to suppress columns. The reason that the xref:refguide:applib:index/services/tablecol/TableColumnVisibilityService.adoc[TableColumnVisibilityService] is needed in addition to this SPI is because of the way that non-null values are handled; as soon as one implementation has an opinion on the order of columns, no other services are consulted. Trying to combine both responsibilities (reordering and filtering only in a single xref:refguide:applib:index/services/tablecol/TableColumnOrderService.adoc[TableColumnOrderService] would result in the user needing to take a lot of care in the relative priority of different implementations. Separating out the filter responsibility in the xref:refguide:applib:index/services/tablecol/TableColumnVisibilityService.adoc[TableColumnVisibilityService] SPIs eliminates these difficulties).

== API

[source,java]
.TableColumnOrderService.java
----
interface TableColumnOrderService {
  List<String> orderParented(Object parent, String collectionId, Class<?> collectionType, List<String> propertyIds)     // <.>
  List<String> orderStandalone(Class<?> collectionType, List<String> propertyIds)     // <.>
}
----

<.> xref:#orderParented_Object_String_Class_List[orderParented(Object, String, Class, List)]
+
--
For the parent collection owned by the specified parent and collection Id, return the set of property ids in the same or other order.
--
<.> xref:#orderStandalone_Class_List[orderStandalone(Class, List)]
+
--
For the standalone collection of the specified type, return the set of property ids in the same or other order.
--

== Members

[#orderParented_Object_String_Class_List]
=== orderParented(Object, String, Class, List)

For the parent collection owned by the specified parent and collection Id, return the set of property ids in the same or other order.

Return `null` if has no opinion/provides no reordering for this parent and collection.

[#orderStandalone_Class_List]
=== orderStandalone(Class, List)

For the standalone collection of the specified type, return the set of property ids in the same or other order.

Return `null` if has no opinion/provides no reordering for this type.

include::hooks/TableColumnOrderService_010-implementation.adoc[]

include::hooks/TableColumnOrderService_020-examples-and-usage.adoc[]
