= GridLoaderService
: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 load the XML layout (grid) for a domain class.

== API

[source,java]
.GridLoaderService.java
----
interface GridLoaderService {
  boolean supportsReloading()     // <.>
  void remove(Class<?> domainClass)     // <.>
  boolean existsFor(Class<?> domainClass, EnumSet<CommonMimeType> supportedFormats)     // <.>
  Optional<T> load(Class<?> domainClass, String layoutIfAny, GridMarshallerService<T> marshaller)     // <.>
  Optional<T> load(Class<?> domainClass, GridMarshallerService<T> marshaller)     // <.>
}
----

<.> xref:#supportsReloading_[supportsReloading()]
+
--
Whether dynamic reloading of layouts is enabled.
--
<.> xref:#remove_Class[remove(Class)]
+
--
To support metamodel invalidation/rebuilding of spec.
--
<.> xref:#existsFor_Class_EnumSet[existsFor(Class, EnumSet)]
+
--
Whether any persisted layout metadata (eg a `.layout.xml` file) exists for this domain class.
--
<.> xref:#load_Class_String_GridMarshallerService[load(Class, String, GridMarshallerService)]
+
--
Optionally returns a new instance of a xref:refguide:applib:index/layout/grid/Grid.adoc[Grid] , based on whether the underlying resource could be found, loaded and parsed.
--
<.> xref:#load_Class_GridMarshallerService[load(Class, GridMarshallerService)]
+
--
Optionally returns a new instance of a xref:refguide:applib:index/layout/grid/Grid.adoc[Grid] , based on whether the underlying resource could be found, loaded and parsed.
--

== Members

[#supportsReloading_]
=== supportsReloading()

Whether dynamic reloading of layouts is enabled.

The default implementation enables reloading for prototyping mode, disables in production

[#remove_Class]
=== remove(Class)

To support metamodel invalidation/rebuilding of spec.

This is called by the xref:refguide:applib:index/mixins/metamodel/Object_rebuildMetamodel.adoc[Object_rebuildMetamodel] mixin action.

[#existsFor_Class_EnumSet]
=== existsFor(Class, EnumSet)

Whether any persisted layout metadata (eg a `.layout.xml` file) exists for this domain class.

If none exists, will return null (and the calling xref:refguide:applib:index/services/grid/GridService.adoc[GridService] will use xref:refguide:applib:index/services/grid/GridSystemService.adoc[GridSystemService] to obtain a default grid for the domain class).

[#load_Class_String_GridMarshallerService]
=== load(Class, String, GridMarshallerService)

Optionally returns a new instance of a xref:refguide:applib:index/layout/grid/Grid.adoc[Grid] , based on whether the underlying resource could be found, loaded and parsed.

The layout alternative will typically be specified through a `layout()` method on the domain object, the value of which is used for the suffix of the layout file (eg "Customer-layout.archived.xml" to use a different layout for customers that have been archived).

[#load_Class_GridMarshallerService]
=== load(Class, GridMarshallerService)

Optionally returns a new instance of a xref:refguide:applib:index/layout/grid/Grid.adoc[Grid] , based on whether the underlying resource could be found, loaded and parsed.

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

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