This commit is contained in:
Fabio Sinibaldi 2021-11-12 12:33:59 +01:00
parent 7550f3307a
commit 41af4e3bc9
2 changed files with 6 additions and 0 deletions

View File

@ -7,9 +7,11 @@ import java.util.List;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
@Getter @Getter
@Setter @Setter
@Slf4j
public class ConstraintCheck<T> { public class ConstraintCheck<T> {
public static <T> ConstraintCheck<T> defaultFor(T toCheck,T defaultValue){ public static <T> ConstraintCheck<T> defaultFor(T toCheck,T defaultValue){
@ -55,6 +57,8 @@ public class ConstraintCheck<T> {
T result=theObject; T result=theObject;
if(isError()) { if(isError()) {
result=theDefault; result=theDefault;
log.debug("Applying default {} for current value {}",theDefault,theObject);
if(theDefault!=null && theDefault instanceof Collection) { if(theDefault!=null && theDefault instanceof Collection) {
Collection defaultCollection=(Collection) theDefault; Collection defaultCollection=(Collection) theDefault;
ArrayList target=new ArrayList(defaultCollection); ArrayList target=new ArrayList(defaultCollection);

View File

@ -85,6 +85,8 @@ public class Files {
} }
public static String fixFilename(String toFix) { public static String fixFilename(String toFix) {
if(toFix.startsWith("\\."))
toFix=toFix.replaceFirst("\\.","_");
String extension=""; String extension="";
if(toFix.contains(".")) { if(toFix.contains(".")) {
//preserve extension //preserve extension