1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2025-09-10 02:39:42 +02:00

Make StringEncoder generic

This commit is contained in:
Florian Schmaus 2018-08-21 09:16:11 +02:00
parent e91a8336f6
commit 7374caefef
7 changed files with 22 additions and 22 deletions

View file

@ -34,7 +34,7 @@ import org.jivesoftware.smack.util.StringUtils;
*/
public class Base32 {
private static final StringEncoder base32Stringencoder = new StringEncoder() {
private static final StringEncoder<String> base32Stringencoder = new StringEncoder<String>() {
@Override
public String encode(String string) {
@ -49,7 +49,7 @@ public class Base32 {
};
private static final String ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ2345678";
public static StringEncoder getStringEncoder() {
public static StringEncoder<String> getStringEncoder() {
return base32Stringencoder;
}

View file

@ -1,6 +1,6 @@
/**
*
* Copyright © 2014-2015 Florian Schmaus
* Copyright © 2014-2018 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -20,14 +20,14 @@ import org.jivesoftware.smack.util.Objects;
public class Base64UrlSafeEncoder {
private static StringEncoder base64UrlSafeEncoder;
private static StringEncoder<String> base64UrlSafeEncoder;
public static void setEncoder(StringEncoder encoder) {
public static void setEncoder(StringEncoder<String> encoder) {
Objects.requireNonNull(encoder, "encoder must no be null");
base64UrlSafeEncoder = encoder;
}
public static StringEncoder getStringEncoder() {
public static StringEncoder<String> getStringEncoder() {
return base64UrlSafeEncoder;
}

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2013-2014 Florian Schmaus
* Copyright 2013-2018 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -21,20 +21,20 @@ package org.jivesoftware.smack.util.stringencoder;
*
* @author Florian Schmaus
*/
public interface StringEncoder {
public interface StringEncoder<O> {
/**
* Encodes an string to another representation.
* Encodes an object to another representation.
*
* @param string
* @param object the object to encode.
* @return the encoded String
*/
String encode(String string);
String encode(O object);
/**
* Decodes an string back to it's initial representation.
* Decodes a string back to it's initial representation.
*
* @param string
* @return the decoded String
* @param string the string to decode.
* @return the decoded object
*/
String decode(String string);
O decode(String string);
}