mirror of
				https://github.com/commons-app/apps-android-commons.git
				synced 2025-10-31 14:53:59 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			66 lines
		
	
	
	
		
			1.5 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
			
		
		
	
	
			66 lines
		
	
	
	
		
			1.5 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
| package fr.free.nrw.commons;
 | |
| 
 | |
| import android.support.annotation.Nullable;
 | |
| 
 | |
| public class License {
 | |
|     private String key;
 | |
|     private String template;
 | |
|     private String url;
 | |
|     private String name;
 | |
| 
 | |
|     /**
 | |
|      * Constructs a new instance of License.
 | |
|      *
 | |
|      * @param key       license key
 | |
|      * @param template  license template
 | |
|      * @param url       license URL
 | |
|      * @param name      licence name
 | |
|      *
 | |
|      * @throws RuntimeException if License.key or Licence.template is null
 | |
|      */
 | |
|     public License(String key, String template, String url, String name) {
 | |
|         if (key == null) {
 | |
|             throw new RuntimeException("License.key must not be null");
 | |
|         }
 | |
|         if (template == null) {
 | |
|             throw new RuntimeException("License.template must not be null");
 | |
|         }
 | |
|         this.key = key;
 | |
|         this.template = template;
 | |
|         this.url = url;
 | |
|         this.name = name;
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * Gets the license key.
 | |
|      * @return license key as a String.
 | |
|      */
 | |
|     public String getKey() {
 | |
|         return key;
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * Gets the license template.
 | |
|      * @return license template as a String.
 | |
|      */
 | |
|     public String getTemplate() {
 | |
|         return template;
 | |
|     }
 | |
| 
 | |
|     public String getName() {
 | |
|         if (name == null) {
 | |
|             // hack
 | |
|             return getKey();
 | |
|         } else {
 | |
|             return name;
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     public @Nullable String getUrl(String language) {
 | |
|         if (url == null) {
 | |
|             return null;
 | |
|         } else {
 | |
|             return url.replace("$lang", language);
 | |
|         }
 | |
|     }
 | |
| }
 | 
