Java is next level for me though. I'm wrapping my head around all the keywords final, public, private, protected. new ways to declare stuff. I have a vary shallow use of OOP but havn't coded anything this deep in a very long time. Doing lots of google when I run into this.
My method of getting there is line by line, I convert the code i wrote in JavaScript to Java and use the Moßgraber open source as my savior and guide. I mean this is how I wrote all my JavaScript bitwig stuff too. thank you <3
So here is my question...
Its super simple to create an indexed wrapper function in JavaScript because of its lack of typed variables.
Code: Select all
function makeIndexedFunction(index, f) {
function indexedFunc(value) {
f(index, value);
}
return indexedFunc
}but in Java its much more complicated.
I'm looking through the Moßgraber code and finding this...
de/mossgrabers/framework/observer/IIndexedValueObserver.java
Code: Select all
// Written by Jürgen Moßgraber - mossgrabers.de
// (c) 2017-2020
// Licensed under LGPLv3 - http://www.gnu.org/licenses/lgpl-3.0.txt
package de.mossgrabers.framework.observer;
/**
* An observer for indexed value change.
*
* @author Jürgen Moßgraber
*
* @param <V> The type of the value
*/
@FunctionalInterface
public interface IIndexedValueObserver<V>
{
/**
* Called if the value has changed.
*
* @param index THe index of the value
* @param value The new value
*/
void update (int index, V value);
}Code: Select all
/**
* An abstract track bank.
*
* @author Jürgen Moßgraber
*/
public abstract class AbstractTrackBankImpl extends AbstractChannelBankImpl<TrackBank, ITrack> implements ITrackBank
{
/** {@inheritDoc} */
@Override
public void addNameObserver (final IIndexedValueObserver<String> observer)
{
for (int index = 0; index < this.getPageSize (); index++)
{
final int i = index;
this.getItem (index).addNameObserver (name -> observer.update (i, name));
}
}
}
I'm also unsure why it is necessary to have such a deep track Abstraction that Moßgraber set up. Is that more just to understand the API and have a clean implementation for the code so you can add quick overrides and such? But it also seems like it is a chore to maintain if there is added features.
I'm going to dig into this further but if you guys got pointers or comments(besides go home noobie
