CodeValueTranslationService.java
/*
* Copyright 2020 Global Crop Diversity Trust
*
* Licensed 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.
*/
package org.gringlobal.service;
import java.io.Serializable;
import java.util.Locale;
import java.util.Optional;
import org.gringlobal.model.CodeValue;
import org.gringlobal.model.CodeValueLang;
import org.gringlobal.service.CodeValueTranslationService.TranslatedCodeValue;
import org.gringlobal.service.filter.CodeValueFilter;
/**
* @author Maxym Borodenko
*/
public interface CodeValueTranslationService extends TranslationService<CodeValue, CodeValueLang, TranslatedCodeValue, CodeValueFilter> {
Optional<TranslatedCodeValue> findTranslatedCodeValue(String groupName, String code, Locale locale);
public static class TranslatedCodeValue extends TranslationService.Translation<CodeValue, CodeValueLang> implements Serializable {
private static final long serialVersionUID = -807586787319251010L;
public static TranslatedCodeValue from(CodeValue codeValue, String title, String description) {
var translatedCodeValue = new TranslatedCodeValue();
translatedCodeValue.entity = codeValue;
translatedCodeValue.title = title;
translatedCodeValue.description = description;
return translatedCodeValue;
}
}
}