Рефакторинг
This commit is contained in:
parent
c3997008a5
commit
346b3029af
@ -33,4 +33,8 @@ public class BoxAnswer {
|
|||||||
@Description("Идентификатор стикера")
|
@Description("Идентификатор стикера")
|
||||||
private Integer stickerId;
|
private Integer stickerId;
|
||||||
|
|
||||||
|
public static BoxAnswer of(String message) {
|
||||||
|
return BoxAnswer.builder().message(message).build();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -26,4 +26,8 @@ public class KeyBoardButtonText extends KeyBoardButton {
|
|||||||
this.label = label;
|
this.label = label;
|
||||||
this.color = (color != null) ? color : ButtonColor.DEFAULT;
|
this.color = (color != null) ? color : ButtonColor.DEFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static KeyBoardButtonText of(String label) {
|
||||||
|
return KeyBoardButtonText.builder().label(label).build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,8 @@ import org.sadtech.social.core.domain.content.Message;
|
|||||||
* @author upagge [08/07/2019]
|
* @author upagge [08/07/2019]
|
||||||
*/
|
*/
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface Filter<T extends Message> {
|
public interface Modifiable<T extends Message> {
|
||||||
|
|
||||||
void processing(T content);
|
void change(T content);
|
||||||
|
|
||||||
}
|
}
|
@ -6,6 +6,7 @@ import org.sadtech.social.core.domain.keyboard.KeyBoardButton;
|
|||||||
import org.sadtech.social.core.domain.keyboard.KeyBoardLine;
|
import org.sadtech.social.core.domain.keyboard.KeyBoardLine;
|
||||||
import org.sadtech.social.core.domain.keyboard.button.KeyBoardButtonText;
|
import org.sadtech.social.core.domain.keyboard.button.KeyBoardButtonText;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -53,12 +54,7 @@ public class KeyBoards {
|
|||||||
* @return {@link KeyBoard}
|
* @return {@link KeyBoard}
|
||||||
*/
|
*/
|
||||||
public static KeyBoard verticalMenuString(String... labelButton) {
|
public static KeyBoard verticalMenuString(String... labelButton) {
|
||||||
KeyBoard.KeyBoardBuilder keyBoard = KeyBoard.builder().oneTime(true);
|
return verticalMenuString(Arrays.asList(labelButton));
|
||||||
for (String label : labelButton) {
|
|
||||||
KeyBoardButton keyBoardButton = KeyBoardButtonText.builder().label(label).payload("{\"button\": \"" + label + "\"}").build();
|
|
||||||
keyBoard.lineKeyBoard(KeyBoardLine.builder().buttonKeyBoard(keyBoardButton).build());
|
|
||||||
}
|
|
||||||
return keyBoard.build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -68,15 +64,30 @@ public class KeyBoards {
|
|||||||
* @return {@link KeyBoard}
|
* @return {@link KeyBoard}
|
||||||
*/
|
*/
|
||||||
public static KeyBoard verticalDuoMenuString(String... labelButton) {
|
public static KeyBoard verticalDuoMenuString(String... labelButton) {
|
||||||
|
return verticalDuoMenuString(Arrays.asList(labelButton));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Возвращает клавиатуру формата 2х(N/2), где N - это количество элементов в переданном списке
|
||||||
|
*
|
||||||
|
* @param labelButton Список названий для кнопок
|
||||||
|
* @return {@link KeyBoard}
|
||||||
|
*/
|
||||||
|
public static KeyBoard verticalDuoMenuString(List<String> labelButton) {
|
||||||
KeyBoard.KeyBoardBuilder keyBoard = KeyBoard.builder().oneTime(true);
|
KeyBoard.KeyBoardBuilder keyBoard = KeyBoard.builder().oneTime(true);
|
||||||
boolean flag = true;
|
boolean flag = true;
|
||||||
KeyBoardLine.KeyBoardLineBuilder keyBoardLine = KeyBoardLine.builder();
|
KeyBoardLine.KeyBoardLineBuilder keyBoardLine = KeyBoardLine.builder();
|
||||||
for (String label : labelButton) {
|
for (int i = 0; i <= labelButton.size() - 1; i++) {
|
||||||
|
String label = labelButton.get(i);
|
||||||
if (flag) {
|
if (flag) {
|
||||||
keyBoardLine.buttonKeyBoard(KeyBoardButtonText.builder().label(label).build());
|
keyBoardLine.buttonKeyBoard(KeyBoardButtonText.of(label));
|
||||||
flag = false;
|
if (i == labelButton.size() - 1) {
|
||||||
|
keyBoard.lineKeyBoard(keyBoardLine.build());
|
||||||
} else {
|
} else {
|
||||||
keyBoardLine.buttonKeyBoard(KeyBoardButtonText.builder().label(label).build());
|
flag = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
keyBoardLine.buttonKeyBoard(KeyBoardButtonText.of(label));
|
||||||
keyBoard.lineKeyBoard(keyBoardLine.build());
|
keyBoard.lineKeyBoard(keyBoardLine.build());
|
||||||
keyBoardLine = KeyBoardLine.builder();
|
keyBoardLine = KeyBoardLine.builder();
|
||||||
flag = true;
|
flag = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user