Ignore:
Timestamp:
01/16/13 17:51:51 (11 years ago)
Author:
adeicke
Message:
  • Removed lombok related annotations and util class
  • Added comments and formating due to match project defaults
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/evaluation/result/UsabilityDefectXmlDescriptionResolver.java

    r1030 r1040  
     1//   Copyright 2012 Georg-August-Universität Göttingen, Germany 
     2// 
     3//   Licensed under the Apache License, Version 2.0 (the "License"); 
     4//   you may not use this file except in compliance with the License. 
     5//   You may obtain a copy of the License at 
     6// 
     7//       http://www.apache.org/licenses/LICENSE-2.0 
     8// 
     9//   Unless required by applicable law or agreed to in writing, software 
     10//   distributed under the License is distributed on an "AS IS" BASIS, 
     11//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
     12//   See the License for the specific language governing permissions and 
     13//   limitations under the License. 
     14 
    115package de.ugoe.cs.autoquest.usability.evaluation.result; 
    216 
     
    1630import de.ugoe.cs.autoquest.usability.evaluation.rule.set.UsabilityRule; 
    1731 
     32/** 
     33 * <p> 
     34 * TODO comment 
     35 * </p> 
     36 *  
     37 * @author Alexander Deicke 
     38 */ 
    1839public class UsabilityDefectXmlDescriptionResolver implements UsabilityDefectDescriptionResolver { 
    19      
     40 
    2041    private static final String DEFAULT_MESSAGES_FILE = "defectDescriptions_en.xml"; 
    21      
    22     private static final UsabilityDefectXmlDescriptionResolver instance = new UsabilityDefectXmlDescriptionResolver(); 
    23      
     42 
     43    private static final UsabilityDefectXmlDescriptionResolver instance = 
     44        new UsabilityDefectXmlDescriptionResolver(); 
     45 
    2446    private DefectDescriptions defectDescriptions; 
    25      
     47 
    2648    private UsabilityDefectXmlDescriptionResolver() { 
    2749        loadDescriptions(); 
    2850    } 
    29      
     51 
    3052    @SuppressWarnings("unchecked") 
    3153    private void loadDescriptions() { 
    32         InputStream inputStream = 
    33                 ClassLoader.getSystemResourceAsStream(DEFAULT_MESSAGES_FILE); 
     54        InputStream inputStream = ClassLoader.getSystemResourceAsStream(DEFAULT_MESSAGES_FILE); 
    3455        try { 
    3556            String packageName = DefectDescriptions.class.getPackage().getName(); 
     
    3859 
    3960            defectDescriptions = 
    40                 ((JAXBElement<DefectDescriptions>) unmarshaller.unmarshal(inputStream)) 
    41                     .getValue(); 
     61                ((JAXBElement<DefectDescriptions>) unmarshaller.unmarshal(inputStream)).getValue(); 
    4262        } 
    4363        catch (Exception e) { 
    44             throw new RuntimeException 
    45                 ("error while initializing usability defect descriptions", e); 
     64            throw new RuntimeException("error while initializing usability defect descriptions", e); 
    4665        } 
    4766        finally { 
     
    5675        } 
    5776    } 
    58      
     77 
    5978    public static UsabilityDefectXmlDescriptionResolver instance() { 
    6079        return instance; 
     
    6382    @Override 
    6483    public DefectDescription descriptionFor(final UsabilityRule usabilityRule) { 
    65         Optional<DefectDescription> guidlineDescription = Iterables.tryFind(defectDescriptions.getDefectDescription(), new Predicate<DefectDescription>() { 
    66              
    67             public boolean apply(DefectDescription defectDescription) { 
    68                 return usabilityRule.ruleIdentifier().equals(defectDescription.getDefectId()); 
    69             } 
    70              
    71         }); 
    72         if(!guidlineDescription.isPresent()) 
    73             throw new RuntimeException 
    74             ("error while initializing usability defect descriptions. No " + 
    75                     "description text available for description " + usabilityRule.ruleIdentifier()); 
     84        Optional<DefectDescription> guidlineDescription = 
     85            Iterables.tryFind(defectDescriptions.getDefectDescription(), 
     86                              new Predicate<DefectDescription>() { 
     87 
     88                                  public boolean apply(DefectDescription defectDescription) { 
     89                                      return usabilityRule.ruleIdentifier() 
     90                                          .equals(defectDescription.getDefectId()); 
     91                                  } 
     92 
     93                              }); 
     94        if (!guidlineDescription.isPresent()) 
     95            throw new RuntimeException( 
     96                                       "error while initializing usability defect descriptions. No " + 
     97                                           "description text available for description " + 
     98                                           usabilityRule.ruleIdentifier()); 
    7699        return guidlineDescription.get(); 
    77100    } 
Note: See TracChangeset for help on using the changeset viewer.