Advertisement
Guest User

list bean properties

a guest
Sep 22nd, 2010
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 2.81 KB | None | 0 0
  1. package com.bla;
  2.  
  3. import java.beans.PropertyDescriptor;
  4.  
  5. import org.springframework.beans.BeanWrapper;
  6. import org.springframework.beans.BeanWrapperImpl;
  7.  
  8. public class Test{
  9.  
  10.     public static class FedModel{
  11.  
  12.         private Boolean use = false;
  13.  
  14.         private String name;
  15.         private String progression;
  16.         private String difficultyLevel;
  17.         private String muscleGroups;
  18.         private String equipment;
  19.         private String benefits;
  20.         private String startingPos;
  21.         private String movement;
  22.  
  23.         public void setUse(final Boolean use){
  24.             this.use = use;
  25.         }
  26.  
  27.         public Boolean getUse(){
  28.             return this.use;
  29.         }
  30.  
  31.         public void setName(final String name){
  32.             this.name = name;
  33.         }
  34.  
  35.         public void setProgression(final String progression){
  36.             this.progression = progression;
  37.         }
  38.  
  39.         public void setDifficultyLevel(final String difficultyLevel){
  40.             this.difficultyLevel = difficultyLevel;
  41.         }
  42.  
  43.         public void setMuscleGroups(final String muscleGroups){
  44.             this.muscleGroups = muscleGroups;
  45.         }
  46.  
  47.         public void setEquipment(final String equipment){
  48.             this.equipment = equipment;
  49.         }
  50.  
  51.         public void setBenefits(final String benefits){
  52.             this.benefits = benefits;
  53.         }
  54.  
  55.         public void setStartingPos(final String startingPos){
  56.             this.startingPos = startingPos;
  57.         }
  58.  
  59.         public void setMovement(final String movement){
  60.             this.movement = movement;
  61.         }
  62.  
  63.         public String getName(){
  64.             return this.name;
  65.         }
  66.  
  67.         public String getProgression(){
  68.             return this.progression;
  69.         }
  70.  
  71.         public String getDifficultyLevel(){
  72.             return this.difficultyLevel;
  73.         }
  74.  
  75.         public String getMuscleGroups(){
  76.             return this.muscleGroups;
  77.         }
  78.  
  79.         public String getEquipment(){
  80.             return this.equipment;
  81.         }
  82.  
  83.         public String getBenefits(){
  84.             return this.benefits;
  85.         }
  86.  
  87.         public String getStartingPos(){
  88.             return this.startingPos;
  89.         }
  90.  
  91.         public String getMovement(){
  92.             return this.movement;
  93.         }
  94.  
  95.     }
  96.  
  97.     public static void main(final String[] args) throws Exception{
  98.         final FedModel thingy = new FedModel();
  99.         thingy.setStartingPos("starting pos 123");
  100.         thingy.setMovement("movement abc");
  101.         final BeanWrapper wrapper = new BeanWrapperImpl(thingy);
  102.         for(final PropertyDescriptor descriptor : wrapper.getPropertyDescriptors()){
  103.             System.out.println(descriptor.getName() + ":"
  104.                 + descriptor.getReadMethod().invoke(thingy));
  105.         }
  106.  
  107.     }
  108.  
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement