Skip to content

Package: LoadableSupport

LoadableSupport

nameinstructionbranchcomplexitylinemethod
getMimeType(FileEntity)
M: 1 C: 11
92%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 0 C: 1
100%
M: 0 C: 1
100%
getSupportedExtensions()
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getSupportedMimeTypes()
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

Coverage

1: /*
2: * *************************************************************************************************************************************************************
3: *
4: * blueMarine III: Semantic DAM
5: * http://tidalwave.it/projects/bluemarine3
6: *
7: * Copyright (C) 2024 - 2025 by Tidalwave s.a.s. (http://tidalwave.it)
8: *
9: * *************************************************************************************************************************************************************
10: *
11: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
12: * You may obtain a copy of the License at
13: *
14: * http://www.apache.org/licenses/LICENSE-2.0
15: *
16: * 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
17: * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
18: *
19: * *************************************************************************************************************************************************************
20: *
21: * git clone https://bitbucket.org/tidalwave/bluemarine3-src
22: * git clone https://github.com/tidalwave-it/bluemarine3-src
23: *
24: * *************************************************************************************************************************************************************
25: */
26: package it.tidalwave.dam.model.spi.role;
27:
28: import jakarta.annotation.Nonnull;
29: import java.util.HashSet;
30: import java.util.Optional;
31: import java.util.Set;
32: import it.tidalwave.dam.model.Entity;
33: import it.tidalwave.dam.model.MimeType;
34: import it.tidalwave.dam.model.io.FileEntity;
35: import it.tidalwave.dam.model.role.Loadable;
36: import lombok.RequiredArgsConstructor;
37:
38: /***************************************************************************************************************************************************************
39: *
40: * A partial implementation of {@link Loadable}.
41: *
42: * @stereotype Role
43: * @see Loadable
44: * @author Fabrizio Giudici
45: *
46: **************************************************************************************************************************************************************/
47: @RequiredArgsConstructor
48: public abstract class LoadableSupport<T extends Entity> implements Loadable<T>
49: {
50: @Nonnull
51: private final Set<String> supportedExtensions;
52:
53: @Nonnull
54: private final Set<MimeType> supportedMimeTypes;
55:
56: /***********************************************************************************************************************************************************
57: * {@inheritDoc}
58: **********************************************************************************************************************************************************/
59: @Override @Nonnull
60: public Set<String> getSupportedExtensions()
61: {
62: return new HashSet<>(supportedExtensions);
63: }
64:
65: /***********************************************************************************************************************************************************
66: * {@inheritDoc}
67: **********************************************************************************************************************************************************/
68: @Override @Nonnull
69: public Set<MimeType> getSupportedMimeTypes()
70: {
71: return new HashSet<>(supportedMimeTypes);
72: }
73:
74: /***********************************************************************************************************************************************************
75: * {@inheritDoc}
76: * If the implementation class registered a single MIME type, it will be returned. Implementation supporting multiple MIME types must override this method
77: * to return the proper MIME type.
78: **********************************************************************************************************************************************************/
79: @Override @Nonnull
80: public Optional<MimeType> getMimeType (@Nonnull final FileEntity ignored)
81: {
82:• return supportedMimeTypes.size() == 1 ? supportedMimeTypes.stream().findFirst() : Optional.empty();
83: }
84: }