fr.ird.observe.dto.referential.I18nReferentialHelper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of common-dto Show documentation
Show all versions of common-dto Show documentation
ObServe Toolkit Common Dto module
package fr.ird.observe.dto.referential;
/*-
* #%L
* ObServe Toolkit :: Common Dto
* %%
* Copyright (C) 2017 - 2020 IRD, Ultreia.io
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* .
* #L%
*/
public class I18nReferentialHelper {
public static String getLabel(int referenceLocaleOrdinal, E i18nDto) {
String result = null;
switch (referenceLocaleOrdinal + 1) {
case 1:
result = i18nDto.getLabel1();
break;
case 2:
result = i18nDto.getLabel2();
break;
case 3:
result = i18nDto.getLabel3();
break;
case 4:
result = i18nDto.getLabel4();
break;
case 5:
result = i18nDto.getLabel5();
break;
case 6:
result = i18nDto.getLabel6();
break;
case 7:
result = i18nDto.getLabel7();
break;
case 8:
result = i18nDto.getLabel8();
break;
}
return result;
}
public static void setLabel(int referenceLocaleOrdinal, E i18nEntity, String label) {
switch (referenceLocaleOrdinal + 1) {
case 1:
i18nEntity.setLabel1(label);
break;
case 2:
i18nEntity.setLabel2(label);
break;
case 3:
i18nEntity.setLabel3(label);
break;
case 4:
i18nEntity.setLabel4(label);
break;
case 5:
i18nEntity.setLabel5(label);
break;
case 6:
i18nEntity.setLabel6(label);
break;
case 7:
i18nEntity.setLabel7(label);
break;
case 8:
i18nEntity.setLabel8(label);
break;
}
}
public static String getPropertyName(int referenceLocaleOrdinal) {
return "label" + (referenceLocaleOrdinal + 1);
}
// public static final Function LABEL1_FUNCTION = WithI18n::getLabel1;
//
// public static final Function LABEL2_FUNCTION = WithI18n::getLabel2;
//
// public static final Function LABEL3_FUNCTION = WithI18n::getLabel3;
//
// public static final Function LABEL4_FUNCTION = WithI18n::getLabel4;
//
// public static final Function LABEL5_FUNCTION = WithI18n::getLabel5;
//
// public static final Function LABEL6_FUNCTION = WithI18n::getLabel6;
//
// public static final Function LABEL7_FUNCTION = WithI18n::getLabel7;
//
// public static final Function LABEL8_FUNCTION = WithI18n::getLabel8;
// public static Class typeOfI18nReferentialDto() {
// return (Class) I18nReferentialDto.class;
// }
// public static void copyI18nReferentialDto(BeanType source, BeanType target) {
// Class sourceType = typeOfI18nReferentialDto();
// Binder binder = BinderFactory.newBinder(sourceType);
// binder.copy(source, target);
// }
//
// public static void copyI18nReferentialDto(BeanType source, BeanType target, Binder binder) {
// binder.copy(source, target);
// }
// public static Predicate newLabel1Predicate(String label1) {
// return o -> Objects.equals(label1, o.getLabel1());
//
// }
// public static List filterByLabel1(Collection $source, String label1) {
// return $source.stream().filter(newLabel1Predicate(label1)).collect(Collectors.toList());
// }
// public static Predicate newLabel2Predicate(String label2) {
// return o -> Objects.equals(label2, o.getLabel2());
//
// }
//
// public static List filterByLabel2(Collection $source, String label2) {
// return $source.stream().filter(newLabel2Predicate(label2)).collect(Collectors.toList());
// }
//
// public static Predicate newLabel3Predicate(String label3) {
// return o -> Objects.equals(label3, o.getLabel3());
//
// }
//
// public static List filterByLabel3(Collection $source, String label3) {
// return $source.stream().filter(newLabel3Predicate(label3)).collect(Collectors.toList());
// }
//
// public static Predicate newLabel4Predicate(String label4) {
// return o -> Objects.equals(label4, o.getLabel4());
//
// }
//
// public static List filterByLabel4(Collection $source, String label4) {
// return $source.stream().filter(newLabel4Predicate(label4)).collect(Collectors.toList());
// }
//
// public static Predicate newLabel5Predicate(String label5) {
// return o -> Objects.equals(label5, o.getLabel5());
//
// }
//
// public static List filterByLabel5(Collection $source, String label5) {
// return $source.stream().filter(newLabel5Predicate(label5)).collect(Collectors.toList());
// }
//
// public static Predicate newLabel6Predicate(String label6) {
// return o -> Objects.equals(label6, o.getLabel6());
//
// }
//
// public static List filterByLabel6(Collection $source, String label6) {
// return $source.stream().filter(newLabel6Predicate(label6)).collect(Collectors.toList());
// }
//
// public static Predicate newLabel7Predicate(String label7) {
// return o -> Objects.equals(label7, o.getLabel7());
//
// }
//
// public static List filterByLabel7(Collection $source, String label7) {
// return $source.stream().filter(newLabel7Predicate(label7)).collect(Collectors.toList());
// }
//
// public static Predicate newLabel8Predicate(String label8) {
// return o -> Objects.equals(label8, o.getLabel8());
//
// }
//
// public static List filterByLabel8(Collection $source, String label8) {
// return $source.stream().filter(newLabel8Predicate(label8)).collect(Collectors.toList());
// }
//
// public static ImmutableMap uniqueIndexByLabel1(Iterable $source) {
// return Maps.uniqueIndex($source, LABEL1_FUNCTION::apply);
// }
//
// public static ImmutableMap uniqueIndexByLabel2(Iterable $source) {
// return Maps.uniqueIndex($source, LABEL2_FUNCTION::apply);
// }
//
// public static ImmutableMap uniqueIndexByLabel3(Iterable $source) {
// return Maps.uniqueIndex($source, LABEL3_FUNCTION::apply);
// }
//
// public static ImmutableMap uniqueIndexByLabel4(Iterable $source) {
// return Maps.uniqueIndex($source, LABEL4_FUNCTION::apply);
// }
//
// public static ImmutableMap uniqueIndexByLabel5(Iterable $source) {
// return Maps.uniqueIndex($source, LABEL5_FUNCTION::apply);
// }
//
// public static ImmutableMap uniqueIndexByLabel6(Iterable $source) {
// return Maps.uniqueIndex($source, LABEL6_FUNCTION::apply);
// }
//
// public static ImmutableMap uniqueIndexByLabel7(Iterable $source) {
// return Maps.uniqueIndex($source, LABEL7_FUNCTION::apply);
// }
//
// public static ImmutableMap uniqueIndexByLabel8(Iterable $source) {
// return Maps.uniqueIndex($source, LABEL8_FUNCTION::apply);
// }
}