Skip to contentPackage: MusicBrainzMetadataProvider
MusicBrainzMetadataProvider
Coverage
1: /*
2: * *********************************************************************************************************************
3: *
4: * blueMarine II: Semantic Media Centre
5: * http://tidalwave.it/projects/bluemarine2
6: *
7: * Copyright (C) 2015 - 2021 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
12: * the License. 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
17: * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations under the License.
19: *
20: * *********************************************************************************************************************
21: *
22: * git clone https://bitbucket.org/tidalwave/bluemarine2-src
23: * git clone https://github.com/tidalwave-it/bluemarine2-src
24: *
25: * *********************************************************************************************************************
26: */
27: package it.tidalwave.bluemarine2.metadata.musicbrainz;
28:
29: import javax.annotation.Nonnull;
30: import java.util.function.Function;
31: import java.io.IOException;
32: import org.musicbrainz.ns.mmd_2.Metadata;
33: import org.musicbrainz.ns.mmd_2.Recording;
34: import org.musicbrainz.ns.mmd_2.Release;
35: import org.musicbrainz.ns.mmd_2.ReleaseGroupList;
36: import org.musicbrainz.ns.mmd_2.ReleaseList;
37: import it.tidalwave.bluemarine2.rest.RestResponse;
38: import lombok.Getter;
39: import lombok.RequiredArgsConstructor;
40: import lombok.ToString;
41:
42: /***********************************************************************************************************************
43: *
44: * @author Fabrizio Giudici
45: *
46: **********************************************************************************************************************/
47: public interface MusicBrainzMetadataProvider
48: {
49: @RequiredArgsConstructor @Getter @ToString(of = "name")
50: public static class ResourceType<TYPE>
51: {
52: @Nonnull
53: private final String name;
54:
55: @Nonnull
56: private final Function<Metadata, TYPE> resultProvider;
57: }
58:
59: public static final ResourceType<Release> RELEASE = new ResourceType<>("release", Metadata::getRelease);
60:
61: public static final ResourceType<Recording> RECORDING = new ResourceType<>("recording", Metadata::getRecording);
62:
63: public static final ResourceType<ReleaseList> DISC_ID = new ResourceType<>("discId", Metadata::getReleaseList);
64:
65: /*******************************************************************************************************************
66: *
67: *
68: *
69: ******************************************************************************************************************/
70: @Nonnull
71: public RestResponse<ReleaseGroupList> findReleaseGroupByTitle (@Nonnull String title, @Nonnull String ... includes)
72: throws IOException, InterruptedException;
73:
74: /*******************************************************************************************************************
75: *
76: *
77: *
78: ******************************************************************************************************************/
79: @Nonnull
80: public RestResponse<ReleaseList> findReleaseListByToc (@Nonnull String toc, @Nonnull String ... includes)
81: throws IOException, InterruptedException;
82:
83: /*******************************************************************************************************************
84: *
85: *
86: *
87: ******************************************************************************************************************/
88: @Nonnull
89: public <T> RestResponse<T> getResource (@Nonnull ResourceType<T> resourceType,
90: @Nonnull String id,
91: @Nonnull String ... includes)
92: throws IOException, InterruptedException;
93: }