javax.json.bind.annotation.JsonbNumberFormat Java Examples

The following examples show how to use javax.json.bind.annotation.JsonbNumberFormat. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HeroFinder.java    From microprofile-graphql with Apache License 2.0 6 votes vote down vote up
@Mutation
@Description("Update an item's powerLevel in percentage") 
public Item updateItemPowerLevelPercentage(@Name("itemID") long itemID,
                                 @JsonbNumberFormat("##'%'") @Name("powerLevel") int newLevel) {
    LOG.log(Level.INFO, "updateItemPowerLevelPercentage invoked [{0}],[{1}]", new Object[]{itemID, newLevel});
    Item item = null;
    for (SuperHero hero : allHeroes()) {
        for (Item i : hero.getEquipment()) {
            if (i.getId() == itemID) {
                item = i;
                item.setPowerLevel(newLevel/20 );
            }
        }
    }
    return item;
}
 
Example #2
Source File: HeroFinder.java    From microprofile-graphql with Apache License 2.0 5 votes vote down vote up
@Mutation
@Description("Update a hero's bank account in US Dollar") 
public SuperHero updateBankBalanceInUS(@Name("name") String name,
                                 @JsonbNumberFormat(value = "¤ ###,###.##",locale = "en-US") 
                                 @Name("bankBalance") Double bankBalance) throws UnknownHeroException {
    LOG.log(Level.INFO, "updateBankBalance invoked [{0}],[{1}]", new Object[]{name, bankBalance});
    SuperHero superHero = heroDB.getHero(name);
    if(superHero!=null){
        superHero.setBankBalance(bankBalance);
    }
    return superHero;
}
 
Example #3
Source File: HeroFinder.java    From microprofile-graphql with Apache License 2.0 5 votes vote down vote up
@Mutation
@Description("Update a hero's favourite drink size in milliliters") 
public SuperHero favouriteDrinkSizeInML(@Name("name") String name,
                                 @JsonbNumberFormat(value = "000.00 'kl'") // This should be ignored due to NumberFormat below
                                 @NumberFormat(value = "###.## 'ml'", locale = "en-GB") 
                                 @Name("size") Float size) throws UnknownHeroException {
    LOG.log(Level.INFO, "favouriteDrinkSizeInML invoked [{0}],[{1}]", new Object[]{name, size});
    SuperHero superHero = heroDB.getHero(name);
    if(superHero!=null){
        superHero.setFavouriteDrinkSize(size);
    }
    return superHero;
}
 
Example #4
Source File: HeroFinder.java    From microprofile-graphql with Apache License 2.0 5 votes vote down vote up
@Mutation
@Description("Update a hero's back account in USD") 
public SuperHero updateNetWorthInUSD(@Name("name") String name,
                                 @JsonbNumberFormat(value = "¤ 000.00",locale = "en-US") 
                                 @Name("netWorth") BigDecimal netWorth) throws UnknownHeroException {
    LOG.log(Level.INFO, "updateBankBalance invoked [{0}],[{1}]", new Object[]{name, netWorth});
    SuperHero superHero = heroDB.getHero(name);
    if(superHero!=null){
        superHero.setNetWorth(netWorth);
    }
    return superHero;
}
 
Example #5
Source File: HeroFinder.java    From microprofile-graphql with Apache License 2.0 5 votes vote down vote up
@Mutation
@Description("Log the last place the hero was seen (Long Lat)") 
public SuperHero logLocationLongLat(@Name("name") String name,
                                 @JsonbNumberFormat(value = "00.0000000 longlat", locale = "en-GB") 
                                 @Name("coordinates") List<BigDecimal> coordinates) throws UnknownHeroException {
    LOG.log(Level.INFO, "logLocationLongLat invoked [{0}],[{1}]", new Object[]{name, coordinates});
    SuperHero superHero = heroDB.getHero(name);
    if(superHero!=null){
        superHero.setLastKnownCoordinates(coordinates);
    }
    return superHero;
}
 
Example #6
Source File: HeroFinder.java    From microprofile-graphql with Apache License 2.0 5 votes vote down vote up
@Mutation
@Description("Log the last few places the hero was seen (Long Lat)") 
public SuperHero trackHeroLongLat(@Name("name") String name,
                    @JsonbNumberFormat(value = "00.0000000 'latlong'") // This should be ignored due to NumberFormat below
                    @Name("coordinates") List<List<@NumberFormat(value = "00.0000000 longlat", locale = "en-GB") BigDecimal>> coordinates) 
        throws UnknownHeroException {
    LOG.log(Level.INFO, "trackHeroLongLat invoked [{0}],[{1}]", new Object[]{name, coordinates});
    SuperHero superHero = heroDB.getHero(name);
    if(superHero!=null){
        superHero.setTrack(coordinates);
    }
    return superHero;
}
 
Example #7
Source File: HeroFinder.java    From microprofile-graphql with Apache License 2.0 5 votes vote down vote up
@Mutation
@Description("Log the last place the hero was seen (Long Lat) using an array") 
public SuperHero logLocationLongLatWithArray(@Name("name") String name,
                                 @JsonbNumberFormat(value = "00.0000000 longlat", locale = "en-GB") 
                                 @Name("coordinates") BigDecimal[] coordinates) throws UnknownHeroException {
    LOG.log(Level.INFO, "logLocationLongLatWithArray invoked [{0}],[{1}]", new Object[]{name, coordinates});
    SuperHero superHero = heroDB.getHero(name);
    if(superHero!=null){
        superHero.setLastKnownCoordinates(Arrays.asList(coordinates));
    }
    return superHero;
}
 
Example #8
Source File: HeroFinder.java    From microprofile-graphql with Apache License 2.0 5 votes vote down vote up
@Mutation
@Description("Set the ID Number for a hero") 
public SuperHero idNumberWithCorrectFormat(@Name("name") String name,
                         @JsonbNumberFormat("ID-00000000") @Name("id") Long idNumber) throws UnknownHeroException {
    LOG.log(Level.INFO, "idNumberWithCorrectFormat invoked [{0}],[{1}]", new Object[]{name, idNumber});
    SuperHero superHero = heroDB.getHero(name);
    if(superHero!=null){
        superHero.setIdNumber(idNumber);
    }
    return superHero;
}
 
Example #9
Source File: Person.java    From tutorials with MIT License 4 votes vote down vote up
@JsonbNumberFormat(locale = "en_US", value = "#0.0")
public BigDecimal getSalary() {
    return salary;
}
 
Example #10
Source File: Person.java    From tutorials with MIT License 4 votes vote down vote up
@JsonbNumberFormat(locale = "en_US", value = "#0.0")
public BigDecimal getSalary() {
    return salary;
}