Break out the isFloating logic in the GsonEqualsChecker
This commit is contained in:
		
							parent
							
								
									010d91a75d
								
							
						
					
					
						commit
						66de46f0c9
					
				| @ -61,6 +61,7 @@ public abstract class MPlugin extends JavaPlugin implements Listener | ||||
| 	// DISABLE | ||||
| 	// -------------------------------------------- // | ||||
| 	 | ||||
| 	@Override | ||||
| 	public void onDisable() | ||||
| 	{ | ||||
| 		// Collection shutdowns. | ||||
|  | ||||
| @ -134,16 +134,7 @@ public class GsonEqualsChecker | ||||
| 			Number oneNumber = one.getAsNumber(); | ||||
| 			Number twoNumber = two.getAsNumber(); | ||||
| 			 | ||||
| 			boolean floating; | ||||
| 			if (oneNumber instanceof LazilyParsedNumber) | ||||
| 			{ | ||||
| 				floating = StringUtils.contains(oneNumber.toString(), '.'); | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| 				floating = (oneNumber instanceof Double || oneNumber instanceof Float); | ||||
| 			} | ||||
| 			 | ||||
| 			boolean floating = isFloating(oneNumber); | ||||
| 			if (floating) | ||||
| 			{ | ||||
| 				// Our epsilon is pretty big in order to see float and double as the same. | ||||
| @ -174,4 +165,13 @@ public class GsonEqualsChecker | ||||
| 		 | ||||
| 		return twoObject == JsonNull.INSTANCE; | ||||
| 	} | ||||
| 	 | ||||
| 	public static boolean isFloating(Number number) | ||||
| 	{ | ||||
| 		if (number instanceof LazilyParsedNumber) | ||||
| 		{ | ||||
| 			return StringUtils.contains(number.toString(), '.'); | ||||
| 		} | ||||
| 		return (number instanceof Double || number instanceof Float); | ||||
| 	} | ||||
| } | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user