Implementing code snippets into Blogger post

1. Using codeformatter.blogspot.rs

 package model;  
   
 import java.util.ArrayList;  
 import javafx.beans.property.IntegerProperty;  
 import javafx.beans.property.ObjectProperty;  
 import javafx.beans.property.SimpleIntegerProperty;  
 import javafx.beans.property.SimpleObjectProperty;  
 import javafx.beans.property.SimpleStringProperty;  
 import javafx.beans.property.StringProperty;  
   
   
 public class ProdajaModel {  
     
   private final IntegerProperty brzina = new SimpleIntegerProperty(this,"brzina");  
   private final ObjectProperty protok = new SimpleObjectProperty(this,"protok");  
   private final IntegerProperty ugovor = new SimpleIntegerProperty(this,"ugovor");  
   private final IntegerProperty id = new SimpleIntegerProperty(this,"id");  
   private final StringProperty imePrezime = new SimpleStringProperty(this,"imePrezime");  
   private final StringProperty adresa = new SimpleStringProperty(this,"adresa");  
   private final ObjectProperty<ArrayList<String>> errorList = new SimpleObjectProperty<>(this, "errorList", new ArrayList<>());  
    
     
   public ProdajaModel() {}  
     
   public ProdajaModel(int brzina,Object protok,int ugovor,int id,String imePrezime,String adresa) {  
     this.brzina.set(brzina);  
     this.protok.set(protok);  
     this.ugovor.set(ugovor);  
     this.id.set(id);  
     this.imePrezime.set(imePrezime);  
     this.adresa.set(adresa);  
   }  
     
   public int getBrzina() {return brzina.get();}  
   public void setBrzina(int brzina) {this.brzina.set(brzina);}  
   public IntegerProperty brzinaProperty() {return brzina;}  
     
   public Object getProtok() {return protok.get();}  
   public void setProtok(int protok) {this.protok.set(protok);}  
   public ObjectProperty protokProperty() {return protok;}  
     
   public int getUgovor() {return ugovor.get();}  
   public void setUgovor(int ugovor) {this.ugovor.set(ugovor);}  
   public IntegerProperty ugovorProperty() {return ugovor;}  
     
   public int getId() {return id.get();}  
   public void setId(int id) {this.id.set(id);}  
   public IntegerProperty idProperty() {return id;}  
     
   public String getImePrezime() {return imePrezime.get();}  
   public void setImePrezime(String imePrezime) {this.imePrezime.set(imePrezime);}  
   public StringProperty imePrezimeProperty() {return imePrezime;}  
     
   public String getAdresa() {return adresa.get();}  
   public void setAdresa(String adresa) {this.adresa.set(adresa);}  
   public StringProperty adresaProperty() {return adresa;}  
     
   public ObjectProperty<ArrayList<String>> errorsProperty() {return errorList;}  
     
   public boolean isValid() {  
      boolean isValid = true;  
    
     if (imePrezime.get() != null && imePrezime.get().equals("")) {  
       errorList.getValue().add(" Ime i prezime moraju biti uneti!");  
       isValid = false;  
     }  
     if (adresa.get().equals("")) {  
       errorList.getValue().add(" Adresa mora biti uneta!");  
       isValid = false;  
     }  
     if (protok.get() == null) {  
       errorList.getValue().add(" Protok mora biti odabran!");  
       isValid = false;  
     }  
     return isValid;  
   }  
     
   public ProdajaModel save() {  
    
     if (isValid()) {  
       return this;  
     }  
      return null;  
    }  
     
     
     
   @Override  
   public String toString() {  
     return   
         "ID: " + id.get() + "\n" +   
         "Ime i prezime: " + imePrezime.get() + "\n" +   
         "Adresa: " + adresa.get() + "\n" +   
         "Ugovor: " + ugovor.get() + " god." + "\n" +   
         "Brzina: " + brzina.get() + " Mbit" +"\n" +   
         "Protok: " + protok.get() + " GB";  
   }  
     
 }  
   


2. Using hilite.me

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package model;

import java.util.ArrayList;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;


public class ProdajaModel {
    
    private final IntegerProperty brzina = new SimpleIntegerProperty(this,"brzina");
    private final ObjectProperty protok = new SimpleObjectProperty(this,"protok");
    private final IntegerProperty ugovor = new SimpleIntegerProperty(this,"ugovor");
    private final IntegerProperty id = new SimpleIntegerProperty(this,"id");
    private final StringProperty imePrezime = new SimpleStringProperty(this,"imePrezime");
    private final StringProperty adresa = new SimpleStringProperty(this,"adresa");
    private final ObjectProperty<ArrayList<String>> errorList = new SimpleObjectProperty<>(this, "errorList", new ArrayList<>());
 
    
    public ProdajaModel() {}
    
    public ProdajaModel(int brzina,Object protok,int ugovor,int id,String imePrezime,String adresa) {
        this.brzina.set(brzina);
        this.protok.set(protok);
        this.ugovor.set(ugovor);
        this.id.set(id);
        this.imePrezime.set(imePrezime);
        this.adresa.set(adresa);
    }
    
    public int getBrzina() {return brzina.get();}
    public void setBrzina(int brzina) {this.brzina.set(brzina);}
    public IntegerProperty brzinaProperty() {return brzina;}
    
    public Object getProtok() {return protok.get();}
    public void setProtok(int protok) {this.protok.set(protok);}
    public ObjectProperty protokProperty() {return protok;}
    
    public int getUgovor() {return ugovor.get();}
    public void setUgovor(int ugovor) {this.ugovor.set(ugovor);}
    public IntegerProperty ugovorProperty() {return ugovor;}
    
    public int getId() {return id.get();}
    public void setId(int id) {this.id.set(id);}
    public IntegerProperty idProperty() {return id;}
    
    public String getImePrezime() {return imePrezime.get();}
    public void setImePrezime(String imePrezime) {this.imePrezime.set(imePrezime);}
    public StringProperty imePrezimeProperty() {return imePrezime;}
    
    public String getAdresa() {return adresa.get();}
    public void setAdresa(String adresa) {this.adresa.set(adresa);}
    public StringProperty adresaProperty() {return adresa;}
    
    public ObjectProperty<ArrayList<String>> errorsProperty() {return errorList;}
    
    public boolean isValid() {
         boolean isValid = true;
 
        if (imePrezime.get() != null && imePrezime.get().equals("")) {
            errorList.getValue().add(" Ime i prezime moraju biti uneti!");
            isValid = false;
        }
        if (adresa.get().equals("")) {
            errorList.getValue().add(" Adresa mora biti uneta!");
            isValid = false;
        }
        if (protok.get() == null) {
            errorList.getValue().add(" Protok mora biti odabran!");
            isValid = false;
        }
        return isValid;
    }
    
    public ProdajaModel save() {
 
        if (isValid()) {
            return this;
        }
         return null;
     }
    
    
    
    @Override
    public String toString() {
        return 
                "ID: " + id.get() + "\n" + 
                "Ime i prezime: " + imePrezime.get() + "\n" + 
                "Adresa: " + adresa.get() + "\n" + 
                "Ugovor: " + ugovor.get() + " god." + "\n" + 
                "Brzina: " + brzina.get() + " Mbit" +"\n" + 
                "Protok: " + protok.get() + " GB";
    }
    
}

Comments