MaxPixConverter.java
1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.scene7.is.util.Converter
* com.scene7.is.util.Size
* com.scene7.is.util.text.converters.SizeConverter
* org.apache.commons.beanutils.ConversionException
* org.jetbrains.annotations.NotNull
*/
package com.scene7.is.ps.provider.parsers;
import com.scene7.is.util.Converter;
import com.scene7.is.util.Size;
import com.scene7.is.util.text.converters.SizeConverter;
import org.apache.commons.beanutils.ConversionException;
import org.jetbrains.annotations.NotNull;
public class MaxPixConverter
extends Converter<String, Size> {
private static final Converter<String, Size> INSTANCE = new MaxPixConverter();
@NotNull
public static Converter<String, Size> maxPixConverter() {
return INSTANCE;
}
@NotNull
public Size convert(@NotNull String value) throws ConversionException {
Size result = (Size)SizeConverter.sizeConverter().convert((Object)value);
double width = result.width;
double height = result.height;
if (width != 0.0 && height != 0.0) {
return result;
}
width = width == 0.0 ? Double.MAX_VALUE : width;
height = height == 0.0 ? Double.MAX_VALUE : height;
return Size.size((double)width, (double)height);
}
@NotNull
public String revert(@NotNull Size src) throws ConversionException {
double width = src.width == Double.MAX_VALUE ? 0.0 : src.width;
double height = src.height == Double.MAX_VALUE ? 0.0 : src.height;
return (String)SizeConverter.sizeConverter().revert((Object)Size.size((double)width, (double)height));
}
private MaxPixConverter() {
super(String.class, Size.class);
}
}