mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
75 lines
1.7 KiB
Java
75 lines
1.7 KiB
Java
package fr.free.nrw.commons;
|
|
|
|
import android.support.annotation.Nullable;
|
|
|
|
/**
|
|
* represents Licence object
|
|
*/
|
|
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;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Gets the license URL
|
|
*
|
|
* @param language license language
|
|
* @return URL
|
|
*/
|
|
public @Nullable String getUrl(String language) {
|
|
if (url == null) {
|
|
return null;
|
|
} else {
|
|
return url.replace("$lang", language);
|
|
}
|
|
}
|
|
}
|