|
| 1 | +// This file was generated by Mendix Studio Pro. |
| 2 | +// |
| 3 | +// WARNING: Only the following code will be retained when actions are regenerated: |
| 4 | +// - the import list |
| 5 | +// - the code between BEGIN USER CODE and END USER CODE |
| 6 | +// - the code between BEGIN EXTRA CODE and END EXTRA CODE |
| 7 | +// Other code you write will be lost the next time you deploy the project. |
| 8 | +// Special characters, e.g., é, ö, à, etc. are supported in comments. |
| 9 | + |
| 10 | +package fakedata.actions; |
| 11 | + |
| 12 | +import java.math.BigDecimal; |
| 13 | + |
| 14 | +import com.github.javafaker.Faker; |
| 15 | +import com.mendix.systemwideinterfaces.core.IContext; |
| 16 | +import com.mendix.webui.CustomJavaAction; |
| 17 | + |
| 18 | +public class GenerateDecimalBetween extends CustomJavaAction<java.math.BigDecimal> |
| 19 | +{ |
| 20 | + private java.lang.Long Min; |
| 21 | + private java.lang.Long Max; |
| 22 | + private java.lang.Long NumberOfDecimals; |
| 23 | + |
| 24 | + public GenerateDecimalBetween(IContext context, java.lang.Long Min, java.lang.Long Max, java.lang.Long NumberOfDecimals) |
| 25 | + { |
| 26 | + super(context); |
| 27 | + this.Min = Min; |
| 28 | + this.Max = Max; |
| 29 | + this.NumberOfDecimals = NumberOfDecimals; |
| 30 | + } |
| 31 | + |
| 32 | + @java.lang.Override |
| 33 | + public java.math.BigDecimal executeAction() throws Exception |
| 34 | + { |
| 35 | + // BEGIN USER CODE |
| 36 | + Faker faker = new Faker(); |
| 37 | + |
| 38 | + Long min = (this.Min > this.Max) ? this.Max : this.Min; |
| 39 | + Long max = (this.Max < this.Min) ? this.Min : this.Max; |
| 40 | + double result = faker.number().randomDouble(this.NumberOfDecimals.intValue(), min, max); |
| 41 | + return BigDecimal.valueOf(result); |
| 42 | + // END USER CODE |
| 43 | + } |
| 44 | + |
| 45 | + /** |
| 46 | + * Returns a string representation of this action |
| 47 | + */ |
| 48 | + @java.lang.Override |
| 49 | + public java.lang.String toString() |
| 50 | + { |
| 51 | + return "GenerateDecimalBetween"; |
| 52 | + } |
| 53 | + |
| 54 | + // BEGIN EXTRA CODE |
| 55 | + // END EXTRA CODE |
| 56 | +} |
0 commit comments