Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.robrua.orianna.type.core.staticdata;
  
  import java.util.HashMap;
  import java.util.List;
  import java.util.Map;
 
 
 public class Item extends OriannaObject<com.robrua.orianna.type.dto.staticdata.Item> {
     private static final Map<StringPatternPATTERNS = getScrapedStatPatterns();
     private static final long serialVersionUID = 8240618175038660294L;

    
Patterns for scraping non-included stat data from item descriptions

Returns:
the patterns
 
     private static Map<StringPatterngetScrapedStatPatterns() {
         final Map<StringPatternpatterns = new HashMap<StringPattern>();
         patterns.put("percentCooldownReduction", Pattern.compile("\\+(\\d+) *% Cooldown Reduction *(<br>|</stats>|</passive>|$)"));
         patterns.put("flatArmorPenetration", Pattern.compile("\\+(\\d+) *Armor Penetration *(<br>|</stats>|</passive>|$)"));
         patterns.put("percentArmorPenetration", Pattern.compile("ignores (\\d+)% of the target's Armor"));
         patterns.put("flatMagicPenetration", Pattern.compile("\\+(\\d+) *Magic Penetration *(<br>|</stats>|</passive>|$)"));
         patterns.put("percentMagicPenetration", Pattern.compile("ignores (\\d+)% of the target's Magic Resist"));
         patterns.put("goldPer10", Pattern.compile("\\+(\\d+) *Gold per 10 seconds *(<br>|</stats>|</passive>|$)"));
 
         return patterns;
     }
 
     private Map<StringStringeffect;
     private List<Stringfromintotags;
     private Gold gold;
     private Image image;
     private Map<StringBooleanmaps;
     private MetaData rune;
 
     private BasicDataStats stats;

    

Parameters:
data the underlying dto
 
     public Item(final com.robrua.orianna.type.dto.staticdata.Item data) {
         super(datacom.robrua.orianna.type.dto.staticdata.Item.class);
     }

    
Colloq

Returns:
colloq
 
     public String getColloq() {
         return super.getString(.getColloq());
     }

    
Consumed

Returns:
consumed
 
     public boolean getConsumed() {
         return super.getBoolean(.getConsumed());
     }

    
Consume on full

Returns:
consume on full
 
     public boolean getConsumeOnFull() {
         return super.getBoolean(.getConsumeOnFull());
     }

    
Depth

Returns:
depth
 
     public int getDepth() {
         return super.getInteger(.getDepth());
     }

    
Description

Returns:
description
 
     public String getDescription() {
         return super.getString(.getDescription());
     }

    
Effect

Returns:
effect
    public Map<StringStringgetEffect() {
        if( == null) {
             = new HashMap<>();
            .putAll(.getEffect());
        }
        return Collections.unmodifiableMap();
    }

    
From

Returns:
from
    public List<StringgetFrom() {
        if( == null) {
             = new ArrayList<>();
            .addAll(.getFrom());
        }
        return Collections.unmodifiableList();
    }

    
Gold

Returns:
gold
    public Gold getGold() {
        if( == null) {
             = new Gold(.getGold());
        }
        return ;
    }

    
Group

Returns:
group
    public String getGroup() {
        return super.getString(.getGroup());
    }

    
Hide from all

Returns:
hide from all
    public boolean getHideFromAll() {
        return super.getBoolean(.getHideFromAll());
    }

    
ID

Returns:
iD
    public int getID() {
        return super.getInteger(.getId());
    }

    
Image

Returns:
image
    public Image getImage() {
        if( == null) {
             = new Image(.getImage());
        }
        return ;
    }

    
In store

Returns:
in store
    public boolean getInStore() {
        return super.getBoolean(.getInStore());
    }

    
Into

Returns:
into
    public List<StringgetInto() {
        if( == null) {
             = new ArrayList<>();
            .addAll(.getInto());
        }
        return Collections.unmodifiableList();
    }

    
Maps

Returns:
maps
    public Map<StringBooleangetMaps() {
        if( == null) {
             = new HashMap<>();
            .putAll(.getMaps());
        }
        return Collections.unmodifiableMap();
    }

    
Name

Returns:
name
    public String getName() {
        return super.getString(.getName());
    }

    
Plain text

Returns:
plain text
    public String getPlainText() {
        return super.getString(.getPlaintext());
    }

    
Required champion name

Returns:
required champion name
    public String getRequiredChampionName() {
        return super.getString(.getRequiredChampion());
    }

    
Rune

Returns:
rune
    public MetaData getRune() {
        if( == null) {
             = new MetaData(.getRune());
        }
        return ;
    }

    
Sanitized description

Returns:
sanitized description
    public String getSanitizedDescription() {
        return super.getString(.getSanitizedDescription());
    }

    
Special recipe

Returns:
special recipe
    public int getSpecialRecipe() {
        return super.getInteger(.getSpecialRecipe());
    }

    
Stacks

Returns:
stacks
    public int getStacks() {
        return super.getInteger(.getStacks());
    }

    
Stats

Returns:
stats
    public BasicDataStats getStats() {
        if( == null) {
             = new BasicDataStats(.getStats());
            scrapeStats();
        }
        return ;
    }

    
Tags

Returns:
tags
    public List<StringgetTags() {
        if( == null) {
             = new ArrayList<>();
            .addAll(.getTags());
        }
        return Collections.unmodifiableList();
    }

    
Scrapes the item description to get stats Riot doesn't send in a workable format
    private void scrapeStats() {
        if( == null) {
            return;
        }
        final Class<BasicDataStatsclazz = BasicDataStats.class;
        for(final String stat : .keySet()) {
            final Matcher matcher = .get(stat).matcher(getDescription());
            if(matcher.find()) {
                try {
                    clazz.getDeclaredField(stat).set(, Double.parseDouble(matcher.group(1)));
                }
                catch(IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) {
                    throw new OriannaException("Error while scraping for Item stats. Report this to the Orianna team.");
                }
            }
        }
    }
    /*
     * (non-Javadoc)
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        return getName();
    }
New to GrepCode? Check out our FAQ X